Code to update ALL fields (inlcudung Headers/Footers...

B

Bill Foley

I have documents that might have several sections with section page
numbering in them and I was looking around for a macro that would update ALL
fields, not just those in the main document or a particular Header/Footer.
I'm sure something exists, but I haven't been able to find it.

Anyone?

TIA!

Bill
 
J

Jay Freedman

I have documents that might have several sections with section page
numbering in them and I was looking around for a macro that would update ALL
fields, not just those in the main document or a particular Header/Footer.
I'm sure something exists, but I haven't been able to find it.

Anyone?

TIA!

Bill

First, to update all the fields in the body of the document (all
sections at once), include the line

ActiveDocument.Fields.Update

Then, to get all the fields in all the headers and footers, adapt the
code in http://word.mvps.org/FAQs/MacrosVBA/UnlinkFldsFromHeaders.htm
by changing ".Unlink" to ".Update" in two places.
 
G

Greg Maxey

Jay,

I realize this is just a nit, but that code will not update a field
contained in a shape anchored to a header or footer.
 
G

Greg Maxey

To just update fields you can simplifiy things a great deal with:

Sub Test()
ActiveDocument.PrintPreview
ActiveDocument.ClosePrintPreview
End Sub
 
B

Bill Foley

Thanks, Greg. I looked at your site, but wasn't sure what Case
6,7,8,9,10,11 was.

Bill
 
B

Bill Foley

Thanks, Jay. I'll check it out.

Bill
Jay Freedman said:
First, to update all the fields in the body of the document (all
sections at once), include the line

ActiveDocument.Fields.Update

Then, to get all the fields in all the headers and footers, adapt the
code in http://word.mvps.org/FAQs/MacrosVBA/UnlinkFldsFromHeaders.htm
by changing ".Unlink" to ".Update" in two places.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup
so all may benefit.
 
G

Greg Maxey

Bill,

The long values 6, 7, 8, 9, 10, and 11 represent the constants for the six
different types of headers and footers that each section has. For some
reason if there is a shape in the header or footer of a document then that
shape isn't processed with other shapes in the shape layer or when the
header or footer is processed so it has to be processed explicitly.
 
B

Bill Foley

Got it. Thanks!

Bill
Greg Maxey said:
Bill,

The long values 6, 7, 8, 9, 10, and 11 represent the constants for the six
different types of headers and footers that each section has. For some
reason if there is a shape in the header or footer of a document then that
shape isn't processed with other shapes in the shape layer or when the
header or footer is processed so it has to be processed explicitly.


--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
 

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