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 / November 2004

Tip: Looking for answers? Try searching our database.

Update fields in header

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter Tragardh - 16 Nov 2004 12:00 GMT
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
Helmut Weber - 16 Nov 2004 12:21 GMT
Hi Peter,
for a full coverage of processing all
kinds of storyranges, see:
http://word.mvps.org/FAQs/Customization/ReplaceAnywhere.htm
In some cases the following might be sufficient:
Dim rStr As Range
For Each rStr In ActiveDocument.StoryRanges
  rStr.Fields.Update
Next
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
Joost Verdaasdonk - 16 Nov 2004 19:29 GMT
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
 
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.