|
Tip>Designer>Word Functions |
|
|
Using FillPoints with Word field formulas |
|
|
Article #: |
0029 |
|
Contributor: |
Joanne Irvine-Smith |
|
GF version: |
All |
|
Applies to: |
FillPoints and field formulas in Microsoft Word |
|
Last updated: |
December 21, 2001 |
Description
Use the values of FillPoint variables and the GhostFill Scripting Language in Word field formulas.
Explanation
A Word field has a default value that is displayed until the field is updated. When you first open an assembled RTF document, the field displays the default value and is not updated. The example below describes how to control the default value so that it is correct on opening the document.
Click here to view the example
The table below uses the RepeatBlockWhile task to create multiple rows and has a Word field to calculate the total of the one column. A running total (highlighted) is kept of the rows and then used as the default value for the Word field.
%[Total = 0; bContinue = True]
|
Description |
Amount |
|
%[RepeatBlockWhile(bContinue)] %[Query('Enter a Description', '')] |
%[Amount =Query('Enter the Amount', '');FormatNum(Amount, 2)]%[Total = Total+Amount]%[bContinue = MsgBox('Adding rows', 'Add another value?')] |
|
TOTAL |
%['{\rtf1{\field{\*\fldinst {\b =SUM(ABOVE) \\# "# ##0.00" }}{\fldrslt {\b ' & FormatNum(Total,2) & '}}}}'] |
When you fill the table, the following occurs:
The first FillPoint sets the Total to "0" and the RepeatBlockWhile condition to "true":
%[Total = 0; bContinue = True]
The first Query box prompts you to enter a description:
The second Query box prompts you to enter an amount:
The amount is formatted with 2 decimal places:
50.00
The Amount then gets added to the Total:
0+50.00=50.00
You are then prompted to continue adding rows or not:
The result of this message box is the condition that the RepeatBlockWhile task is based on. If you click OK, the block will be repeated and you can add another description and amount. When you have finished adding items, click Cancel.
The final Total is filled in to the Word field and the result is displayed in the last row of the table. The table will then, for example, look similar to the following:
|
Description |
Amount |
|
Paper |
50.00 |
|
Envelopes |
30.00 |
|
Pens |
15.00 |
|
TOTAL |
95.00 |
|
NOTE |
|
This method of using FillPoints together with Word field formulas is particularly effective for the following reasons:
|