How do I get automatically updated fields in the header? I have a template
file that is large. I would like the Heading 1 (i.e. Introduction, Chapter
1, etc.) to appear in the header. I would like the header to automatically
update from a single macro instead of the recommended way of changing the
previous header manually. I am also a novice when it comes to creating Word
Macros
G.G.Yagoda - 25 Feb 2005 05:52 GMT
The easiest way to update all fields in a document is to switch to the
Print Preview view then back.
ActiveDocument.PrintPreview
Selection.EscapeKey
Slightly crude, but it works.
Doug Robbins - 25 Feb 2005 10:30 GMT
To close Print Preview you can use
ActiveDocument.ClosePrintPreview
Of course using Print Preview will only work if the Update Fields option is
set under Tools>Options>Print. If it is not, you will need to iterate
through all of the headers footers in the document using
Dim i as Long
For i = 1 to ActiveDocument.Sections.Count
With ActiveDocument.Sections(i)
.Headers(wdHeaderFooterFirstPage).Range.Fields.Update
.Headers(wdHeaderFooterPrimary).Range.Fields.Update
.Footers(wdHeaderFooterFirstPage).Range.Fields.Update
.Footers(wdHeaderFooterPrimary).Range.Fields.Update
End With
Next i

Signature
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.
Hope this helps,
Doug Robbins - Word MVP
> The easiest way to update all fields in a document is to switch to the
> Print Preview view then back.
[quoted text clipped - 3 lines]
>
> Slightly crude, but it works.
Charles Kenyon - 25 Feb 2005 16:24 GMT
Rather than use a macro, consider using the StyleRef field. In my experience
(at least in Word 2003) the StyleRef field is one of the few fields in Word
that seems to update automatically.
The following updates fields in headers and footers as well as in the main
doucment.
Private Sub FieldsUpdateAllStory()
' All Story Field Updater
' Written by Charles Kyle Kenyon 9 December 2004
' repaired with help from Jezebel 10 December 2004
' Note, if used in protected form this will reset
' formfields to their defaults
Dim oStory As Range
On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
Do
oStory.Fields.Update
Set oStory = oStory.Next
Loop Until oStory Is Nothing
Next
End Sub

Signature
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.
> How do I get automatically updated fields in the header? I have a
> template
[quoted text clipped - 6 lines]
> Word
> Macros