How to update fields inside containers within a header?

A

AndyE

Within VBA code I wish to update all fields in a document before a save.
This is fine for the body (activedocument.fields.update) and I have managed
to update those within the footer. However, I have a document property field
inside a text box in the header and I cannot fnd a way to get this to update.
Any suggestions please?
 
G

Greg Maxey

AndyE,

You need to cycle through the different document storyranges:

Sub UpdateAllFields()
Dim pRange As Word.Range
For Each pRange In ActiveDocument.StoryRanges
Do
pRange.Fields.Update
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
Next
End Sub
 
A

AndyE

Thanks Greg. I'll try this
--
AndyE


Greg Maxey said:
AndyE,

You need to cycle through the different document storyranges:

Sub UpdateAllFields()
Dim pRange As Word.Range
For Each pRange In ActiveDocument.StoryRanges
Do
pRange.Fields.Update
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
Next
End Sub


--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
 

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