Problems and Solutions>Run-time Assembly

FillPoints in headers and footers

 

Article #:

0003

Contributor:

Daniel Todes

GF version:

3.05

Applies to:

Headers and footers in Microsoft Word templates

Last updated:

June 4, 2001

Problem

FillPoints in headers and footers in a Word template (as opposed to an RTF Template) do not get filled.

Description

In Word, headers and footers are treated as a separate part of a document. When you fill a Word template, the GhostFill Word Desktop Client overlooks the contents of headers and footers. You can work around this by using Word Document Property fields in headers and footers and then setting the values for these fields from FillPoints in the template.

Solution

Click here to view a solution.

For example:

If you have the Word Document Property fields <ProjectName> in the header and <EffectiveDate> and <Version> in the footer, you would set the values as follows:

%[DocProperty.ProjectName='THE KNOWLEDGE BASE PROJECT']

%[DocProperty.EffectiveDate=FormatDate(ProjectDate,'mmmm,yyyy')]

%[DocProperty.Version=VersionNumber].

 

You then need to run the following script to update the headers and footers:

%[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]

It is advisable to store this code in a Clause. This way, you can access it from more than one template without repeating the script each time. Insert a FillPoint into the template to select the Clause that contains the script. For example:

%[Clauses.Select('\KB Project','Update Headers and Footers')].

 

NOTE

You can insert FillPoints directly into headers and footers in an RTF templateor a Text template and they will be filled at run time.

Template Example