Update fields in header

P

Peter Tragardh

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
 
J

Joost Verdaasdonk

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top