I'm trying to update fields (like document name and last saved) when the
document opens, in contrast to the regular update wich only happens when
printing (and print related actions like preview). When the fielsd are
placed in the main document, this code in ThisDocument works:
Private Sub Document_Open()
ActiveDocument.Fields.Update
End Sub
But when the fields are placed in the header, they aren't updated. This is
my problem. Any suggestions?
/Peter
Helmut Weber - 16 Nov 2004 12:21 GMT
Hi Peter,
for a full coverage of processing all
kinds of storyranges, see:
http://word.mvps.org/FAQs/Customization/ReplaceAnywhere.htm
In some cases the following might be sufficient:
Dim rStr As Range
For Each rStr In ActiveDocument.StoryRanges
rStr.Fields.Update
Next
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
Joost Verdaasdonk - 16 Nov 2004 19:29 GMT
Hi Peter,
Like Helmut says its the storyranges that you have to go
trough.
Helmuts code goes through the main story's.
This one goes through the story (ranges) in those story's:
Sub UpdateItAll()
Dim oRange As Word.Range
For Each oRange In ActiveDocument.StoryRanges
Do
oRange.Fields.Update
Set oRange = oRange.NextStoryRange
Loop Until oRange Is Nothing
Next
Set oRange = Nothing
End Sub
Hope this helps,
Groetjes,
Joost Verdaasdonk