Fields in header and update using VBA

B

Blah

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
 
D

Doug Robbins - Word MVP

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

--
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
 
C

Charles Kenyon

Note also that a docvariable field in a header or footer will crash Word 97.
--
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


--------- --------- --------- --------- --------- ---------
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top