Bevos
asked on
Word 2010 Macro Help: Updating bookmark
I have several bookmark fields in a document (BrandName, Title, ReportNumber, Revised Date, OriginalDate) which are referenced in various places I want to update them via a macro. My macro is working really well for the majority of the document but these bookmark fields in the header are always unaffected after I run the macro.
The macro I am using is very simple:
Sub UpdateFields()
On Error Resume Next
ActiveDocument.StoryRanges (wdMainTex tStory).Fi elds.Updat e
ActiveDocument.StoryRanges (wdPrimary FooterStor y).Fields. Update
ActiveDocument.StoryRanges (wdPrimary HeaderStor y).Fields. Update
End Sub
Could anyone please help me find a solution?
The macro I am using is very simple:
Sub UpdateFields()
On Error Resume Next
ActiveDocument.StoryRanges
ActiveDocument.StoryRanges
ActiveDocument.StoryRanges
End Sub
Could anyone please help me find a solution?
ASKER
Thanks Graham, but this one isn't showing up in my list of Macros in Word 2010 (View -> Macros). I tried removing the text in ( ) after the sub and it will show up. Thoughts?
That's because it needs a parameter.
You can call it from a modified version of your original sub
You can call it from a modified version of your original sub
Sub UpdateFields()
UpdateAllFields ActiveDocument
End Sub
ASKER
Hi Graham now I can definitely run the update script but it works much like before. The header area doesn't 'update' automatically. It is required that I right click and select 'update field' from the menu to get the updated value to populate the reference. If it makes a difference these elements are contained in a small table in the header area.
Thanks again for all the help,
Bev
Thanks again for all the help,
Bev
Interesting. Theory says that it should, but I'll test it out.
It works in my tests, buy they could be too simple. Could you post a small sample document, please?
I am using Time fields (with seconds).
I am using Time fields (with seconds).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window