Tip>Designer>Word Functions

Updating fields in headers and footers

 

Article #:

0002

Contributor:

Joanne Irvine-Smith

GF version:

3.05

Applies to:

Fields in headers and footers in Microsoft Word

Last updated:

May 21, 2001

Description

Updates the fields in headers and footers in all the sections of an active Word document.

Explanation

Fields in headers and footers whose values contain variables or FillPoints do not automatically update after a fill. When the document is presented to a user, these fields can contain seemingly garbage values.

 

Click here for a detailed explanation.

To update the fields in a header and footer you need to include script in your template that will look similar to this:

%[i=1;n=WordApp.ActiveDocument.Sections.Count]

%[RepeatBlockWhile(i<=n)]%[~x=WordApp.ActiveDocument.Sections(i).Headers(1).Range.Fields.Update();~x=WordApp.ActiveDocument.Sections(i).Footers(1).Range.Fields.Update();i=i+1]%[EndBlock]

The fields in a header and footer are accessible only through the Sections object. The RepeatBlockWhile task is necessary to iterate through each section.

 

Template Example