Hi everyone,
I have a template setup including a userform, and a couple of different
sections with Ref fields in the footers. I want my code on the OK button in
the userform to cycle through all the footers in the document and update the
fields.
ActiveDocument.Fields.Update seems to completely ignore the headers/footers.
I've tried recording a macro that goes to the footer, selects all and
updates the fields. I put that code into a For Each headerfooter in
headerfooters...next loop, without success. Likewise everything else I've
tried works only for the first section then bombs out.
Can anyone point me in the right direction please?
Thanks in advance,
Helen
Helen - 09 Aug 2007 21:09 GMT
Hi again, I've just spotted the post from jerem below on "Deleting a
specific field code in footers" and used his loop - it works beautifully for
my purposes!! Thanks jerem :-)
cheers, Helen
> Hi everyone,
>
[quoted text clipped - 15 lines]
>
> Helen
Russ - 12 Aug 2007 18:55 GMT
Helen,
This code should update all fields:
Sub UpdateAllFields()
Dim oStory As Range
For Each oStory In ActiveDocument.StoryRanges
oStory.Fields.Update
If oStory.StoryType <> wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
oStory.Fields.Update
Wend
End If
Next oStory
Set oStory = Nothing
End Sub
As to your code, if it did work for the first section, then you should be
able to encapsulate it with:
Dim aSection as Word.Section
For each aSection in ActiveDocument.Sections
***Your code here
Next aSection
> Hi everyone,
>
[quoted text clipped - 14 lines]
>
> Helen

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID