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 / January 2006

Tip: Looking for answers? Try searching our database.

Fields in header and update using VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Blah - 17 Jan 2006 04:54 GMT
Hello all, I'm trying to automate some fields in the header and footer by
making a VBA userform and having it plug into document.  While I can use
document vars to plug in values in the regular bodytext and use
activedocument.fields.update to show the new values, this won't work for
header and footer fields.  I would need to view the header and footer and
refresh manually with F9.  Any suggestions?  Thanks
Doug Robbins - Word MVP - 17 Jan 2006 05:14 GMT
Dim i As Long
With ActiveDocument
   For i = 1 To .Sections.Count
       With .Sections(i)
           .Headers(wdHeaderFooterFirstPage).Range.Fields.Update
           .Headers(wdHeaderFooterPrimary).Range.Fields.Update
           .Footers(wdHeaderFooterFirstPage).Range.Fields.Update
           .Footers(wdHeaderFooterPrimary).Range.Fields.Update
       End With
   Next i
End With

or maybe

With ActiveDocument
   .PrintPreview
   .ClosePrintPreview
End With

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Hello all, I'm trying to automate some fields in the header and footer by
> making a VBA userform and having it plug into document.  While I can use
> document vars to plug in values in the regular bodytext and use
> activedocument.fields.update to show the new values, this won't work for
> header and footer fields.  I would need to view the header and footer and
> refresh manually with F9.  Any suggestions?  Thanks
Charles Kenyon - 17 Jan 2006 06:39 GMT
Note also that a docvariable field in a header or footer will crash Word 97.
Signature

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

> Hello all, I'm trying to automate some fields in the header and footer by
> making a VBA userform and having it plug into document.  While I can use
> document vars to plug in values in the regular bodytext and use
> activedocument.fields.update to show the new values, this won't work for
> header and footer fields.  I would need to view the header and footer and
> refresh manually with F9.  Any suggestions?  Thanks

Rate this thread:






 
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.