Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2006

Tip: Looking for answers? Try searching our database.

Update Fields within a TextBox within a Header

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brent McIntyre - 21 Jul 2004 12:54 GMT
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"
   Else
       MsgBox "Field " & ActiveDocument.Fields.Update & _
           " has an error"
   End If

This has worked fine when the field is within a document, but it has now ceased to work.

Any assistance you may be able to provide would be greatly appreciated.

Yours sincerely,

Brent McIntyre
Jezebel - 21 Jul 2004 13:37 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.