To update all the fields in a document, wherever they are location, use code
like this:
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
> Good evening all,
>
> I am having trouble updating fields automatically that are within a TextBox within a Header of a Document Template. I have been using the
standard update programming shown within Microsoft Word Visual Basic Help
ie.
> If ActiveDocument.Fields.Update = 0 Then
> MsgBox "Update Successful"
[quoted text clipped - 10 lines]
>
> Brent McIntyre
Brent McIntyre - 22 Jul 2004 10:27 GMT
Jezebel,
Thanks for the tip I will give it a try !
Yours sincerely,
Brent McIntyre
Derek - 21 Sep 2006 20:22 GMT
Hi Jezebel.
I have the same challenge as Brent. I'm trying to update docvariable fields
within text boxes that are located in headers/footers.
The code you provided updates all fields except for my docvariable fields
within textboxes that are located in headers/footers.
I am at a loss.
best wishes from Western Canada
sugarborosnerd
...
> To update all the fields in a document, wherever they are location, use code
> like this:
[quoted text clipped - 30 lines]
> >
> > Brent McIntyre
Jezebel - 21 Sep 2006 22:21 GMT
This will do it --
Dim pRange As Word.Range
Dim pShape As Word.Shape
On Error Resume Next
For Each pRange In ActiveDocument.StoryRanges
Do
pRange.Fields.Update
For Each pShape In pRange.ShapeRange
pShape.TextFrame.TextRange.Fields.Update
Next
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
Next
on error goto 0
The 'on error resume next' is needed because the ShapeRange reference throws
an error for some storyranges.
> Hi Jezebel.
> I have the same challenge as Brent. I'm trying to update docvariable
[quoted text clipped - 43 lines]
>> >
>> > Brent McIntyre
Derek - 22 Sep 2006 16:40 GMT
Jezebel, yes it does. I can't thank you enough.
best wishes from Western Canada,
/Derek
> This will do it --
>
[quoted text clipped - 63 lines]
> >> >
> >> > Brent McIntyre