The following may help. I found it in my code snippets.
Sub FieldUpdater()
' Macro to update fields in document other than Ask and Fill-In fields
' Written 19 March 2004 by Charles Kyle Kenyon
' with suggestions from Graham Mayor and Suzanne Barnhill
Dim bUpdate As Boolean
bUpdate = Options.UpdateFieldsAtPrint
Options.UpdateFieldsAtPrint = True
ActiveDocument.PrintPreview
ActiveDocument.ClosePrintPreview
Options.UpdateFieldsAtPrint = bUpdate
End Sub
Adding:
ActiveDocument.Fields.Update
should catch all fields in the document body itself
Otherwise, the following updates Ref fields in all stories. You could take
out the test for the field type to have it apply to all fields.
Sub RefFieldUpdateAllStory()
' Written by Charles Kyle Kenyon 15 November 2001
' All Story Field Updater - Ref fields
Dim oField As Field
Dim oStory As Range
On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
For Each oField In ActiveDocument.Range.Fields
'If oField.Type = wdFieldRef Then
oField.Update
'End If
Next oField
Next oStory
End Sub
(I think the second macro will take longer because it cycles through the
stories and the fields collection.)
I know that I would not want a macro jerking the styles that I changed in a
document back to some standard, but you may live with different needs than I
do. (I would quickly get around such a macro by creating different styles to
use.) Take a look at the vba FAQ page on the MVP FAQ site for the article on
pseudo auto macros. It gives a way to put a macro that will run everytime a
document is opened into a global template.
--
Charles Kenyon
Word New User FAQ & Web Directory:
http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
http://addbalance.com/usersguide
See also the MVP FAQ:
http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.