Microsoft Office Tutorials and References
In Depth Information
Updating All Fields
If Err.Number = 0 Then¶
Err.Clear¶
Exit For¶
Else¶
Err.Clear¶
End If¶
Next¶
End If¶
End With¶
End Sub¶
Updating All Fields
Wrd
With this procedure, you can update all fields in all parts of a document at
once.
Example file:
W006
Scenario: Depending on the location of fields in a
document and which options are set, the data in a field may
or may not be up-to-date. There is no way to tell Word, short
of printing a document with "Update fields" activated in Tools
| Options | Print, to update all the fields in the document.
This macro forces fields to update in every nook and cranny
("story") of a document, including drawing objects, headers
and footers in every section, footnotes, endnotes, etc.
View the Appendix to learn how to store this procedure
in a Standard module.
Option explicit¶
' * * * * *¶
Sub UpdateAllFields()¶
'Variable declaration¶
Dim story As Word.Range¶
For Each story In ActiveDocument.StoryRanges¶
story.Fields.Update¶
Do Until story.NextStoryRange Is Nothing¶
Set story = story.NextStoryRange¶
story.Fields.Update¶
Loop¶
Next¶
End Sub¶
 
Search JabSto ::




Custom Search