Mail merge toggle field codes number format
A very specific question!
In Microsoft Word's mail merge feature, toggle field codes allow you to dynamically switch between different field codes or text. When it comes to number formatting, you can use the NUMFORMAT
field code to specify the format of a numeric field.
Here's an example of how you can use a toggle field code to switch between different number formats:
Suppose you have a field called Amount
that contains a numeric value, and you want to display it in either currency format or decimal format depending on a toggle field called CurrencyFormat
.
You can use the following syntax:
{ IF { TGL "CurrencyFormat" } = "True" THEN "\$#,##0.00" ELSE "#,##0.00" }
Here's how it works:
{ TGL "CurrencyFormat" }
is the toggle field code that checks the value of theCurrencyFormat
field. If it'sTrue
, the code inside theIF
statement will be executed.IF { TGL "CurrencyFormat" } = "True" THEN
checks if the value of theCurrencyFormat
field isTrue
. If it is, the code inside theTHEN
clause will be executed.\$#,##0.00
is the currency format you want to apply if theCurrencyFormat
field isTrue
.ELSE
specifies the alternative format to use if theCurrencyFormat
field is notTrue
.#,##0.00
is the decimal format you want to apply if theCurrencyFormat
field is notTrue
.
When you merge the document, the NUMFORMAT
field code will be replaced with the specified format depending on the value of the CurrencyFormat
toggle field.
Note that you can customize the number formats to suit your specific needs. For example, you can use #,##0
for a plain decimal format or #,##0.00
for a decimal format with two decimal places.