There are excellent macros to update all fields in Microsoft Word documents (including headers and footers). Just like this one: Macro to update all fields in a word document
But what if headers and footers contain text boxes with fields? Sure, it would be better to not have any textbox there, but what if there is no other solution?
For instance, it could be applied to a problem like that:
We should make a text document template with standard form like this one: GOST standard form for text documents Every sheet contains a frame with a bottom table and a left-side table with some fields, like a document number, revisions, etc.
As for me, the better way to do it is to use references to Custom Document Properties in fields placed in a footer. But there should be tables which take a lot of space shrinking the main text area. To prevent this, we could move these tables into a large text box on a different layer. The only problem is how to update fields in this text box...
It could be achieved following these steps:
Get Active Document
Iterate through Footers in Active Document
Iterate through Shapes in Footers in Active Document
If the Shape has Text then
Update Fields in the Shape
End IF
Next
Next
So, the way to the object is: ActiveDocument -> Footer -> TextBox -> Field
The problem is how to go there. Microsoft Word-VB reference says nothing about the situations like that.
Test document: Test MS-Word document with fields in a footer
Document has 4 custom properties to change:
- Document Number
- Document Name
- Product Type
- Parent Number
Shapes
collection, soFor Each oShp In rngStory.ShapeRange
covers it. – Cindy Meister