|
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
Click here to view an example of this solution in a template.
|
{ DocProperty "Transfer"\ *MERGEFORMAT } { DocProperty "EffectiveDate"\ *MERGEFORMAT } |
|
%[Transfer=Dialogs.Select("\Demo\Transfer","")] %[DocProperty.Transfer=Transfer.Name&' - Transfer']%[DocProperty.EffectiveDate=FormatDate(Date(),"mmmm dd, yyyy")]%[Clauses.Select('\KB', 'Update Headers and Footers')]
%[FormatDate(Transfer.Date, 'mmmm dd, yyyy')] %[Transfer.Name] %[Transfer.Address]
Dear %[Transfer.Name]
Property Transfer: %[Transfer.Property]
The amount of $%[Transfer.Amount] is owed by you for the transfer of the above property. Please could you contact our offices at your earliest convenience to arrange payment.
Yours sincerely
P Anderson Attorney WILLOWMORE RUSKMAT & SMITH (Our Ref: PA/MB)
|
|
NOTE |
|
It is advisable to store the update script in a Clause. That way, you can access it from your templates without having to repeat the script. In the example above the script is stored in the Update Headers and Footers Clause. |
Click here to view a document generated from this template.
|
Janet Lee - Transfer August 2001 |
|
August 10, 2001 Janet Lee 24 Albert Road Scottsville, New York USA 14546
Dear Janet Lee
Property Transfer: 32151
The amount of $15,000.00 is owed by you for the transfer of the above property. Please could you contact our offices at your earliest convenience to arrange payment.
Yours sincerely
P Anderson Attorney WILLOWMORE RUSKMAT & SMITH (Our Ref: PA/MB)
|