xSmityx
03-26-2016, 02:01 PM
Quick background: I've created a form that through user input it creates bookmarks throughout the document as they're typing and using the form. They run a Keystroke attached to Alt+P designated to print out the index.
When the index is printed out, it creates headings that relate to the bookmarks created. I then insert a cross reference to the bookmark and input the page number. Thus creating an updateable field so that if pages get shifted around, all the user has to do is update the fields and the cross references get updated to the correct page number. Here's an example of the index being generated:
EXHIBITS Page #
Plaintiff's Exhibit 1 3
Plaintiff's Exhibit 2 5
Now what I want to have happen is at the end of the index printing out that it updates the fields automatically so that they don't have to do it. These indexes being generated have the potential to span over several pages so the first few pages won't have correct page numbers. Here's the code I'm currently using:
Selection.WholeStory
Selection.Fields.Update
Selection.EndKey Unit:=wdStory
So this code is at the very end of the function. When I insert a breakpoint and step through it, it works. When I let the code run without the breakpoint it doesn't work. I've assigned this piece of code to a separate macro for now reminding the users to update the fileds at the end using Alt+Shift+U. At which point it runs this code and works just fine. So for whatever reason the only issue I'm having is that when the code is at the end of the function generating the index, it does not execute successfully.
Any ideas on a solution to this problem would be much appreciated.
When the index is printed out, it creates headings that relate to the bookmarks created. I then insert a cross reference to the bookmark and input the page number. Thus creating an updateable field so that if pages get shifted around, all the user has to do is update the fields and the cross references get updated to the correct page number. Here's an example of the index being generated:
EXHIBITS Page #
Plaintiff's Exhibit 1 3
Plaintiff's Exhibit 2 5
Now what I want to have happen is at the end of the index printing out that it updates the fields automatically so that they don't have to do it. These indexes being generated have the potential to span over several pages so the first few pages won't have correct page numbers. Here's the code I'm currently using:
Selection.WholeStory
Selection.Fields.Update
Selection.EndKey Unit:=wdStory
So this code is at the very end of the function. When I insert a breakpoint and step through it, it works. When I let the code run without the breakpoint it doesn't work. I've assigned this piece of code to a separate macro for now reminding the users to update the fileds at the end using Alt+Shift+U. At which point it runs this code and works just fine. So for whatever reason the only issue I'm having is that when the code is at the end of the function generating the index, it does not execute successfully.
Any ideas on a solution to this problem would be much appreciated.