Toggle Switch Code For Mail Merge
Toggle Switch Code For Mail Merge
Toggle Switch Code For Mail Merge
Tip
To edit existing merge fields, select the entire merge field which is shown enclosed in chevrons
«NLSField» and press Shift+F9 to reveal the field code (or right click on the merge field and
select Toggle Field Codes) which will then be shown enclosed in braces {MERGEFIELD
NLSField}. Once the merge field has been modified, place the cursor within the braces and press
F9 to hide the field code.
To toggle all of the merge fields in a document, press Alt+F9.
Merge fields can be nested and to enclose existing merge fields within a new merge field, select
the existing merge field and press Ctrl+F9. This will result in the merge field being enclosed in
braces {«NLSField»}.
Important
Beginning with NLS 5.13, changes were made to the way mail merge documents are processed
by NLS. Please test all existing Microsoft Word mail merge documents when upgrading to NLS
5.13 and later to ensure that all the merge fields in the document are being processed correctly.
String Formatting
To apply font formatting, add a format switch \* Charformat and apply font formatting to the
‘M’ in MERGEFIELD.
Example
Example
Switch Description
\* Caps Capitalizes the first letter of each word.
\* FirstCap Capitalizes the first letter of the first word.
\* Upper Capitalizes all letters.
\* Lower All letters are in lower case.
To apply number and currency formatting, add a numeric format switch \#.
Switch Description
Specifies the minimum numeric places to display including leading zeroes.
0 (zero) Example
Example
x
{MERGEFIELD cifno \# x##} displays 111 if cifno is 123111
{MERGEFIELD current_interest_rate \# 0.00x} displays 0.599 if
current_interest_rate is .59911
. (decimal
Places a decimal point in its position.
point)
Places a digit grouping symbol (thousand separator) as specified in the regional
settings in the Control Panel.
, (comma)
Example
Example
+ (plus) Example
() Example
(parenthesis)
{MERGEFIELD current_payoff_balance \# "$,0.00;($,0.00);'-'"} displays
$1,234.56 for a positive, (1,234,56) for a negative number, and - for zero.
NotE
Zero values can be suppressed by adding a final semicolon ; at the end (\# "$,0.00;($,0.00);").
This suppresses 0s resulting from empty fields and from fields containing 0s.
To left justify the numbers, enclose the switch parameter in quotes \# "$,0.00" and insert a tab
into the field code after the $ sign.
Example
To show a past due balance in a different font style when it is over a certain amount, an “if, then,
else” field can be used.
Example
Use Set Val to force the display of $0.00 for fields that are empty.
Example
Example
NLS stores its percentage figures as-is (e.g. 5.01% is stored as 5.01). This can be converted into
a decimal number.
The precision of the result, as set by 0.00, can be from '0' to '0.000000000000000'.
Note
After pressing F9 to hide the field code, the merge field may display a syntax error. However, the
merge field will function correctly in NLS as long as the code was entered correctly.
Date Formatting
Switch Description
yyyy Year. Use yy to display the last two digits of any year.
Month. Use MMMM to fully spell out the month (e.g. September, October). Use MMM
to display the three letter abbreviation for the month (e.g. Sep, Oct). Use MM to display
M
the month in two digits with a leading zero for single digit months (e.g. 09, 10). Use M to
display the month in digits (e.g. 9, 10).
Day. Use dddd to spell out the day of the week (e.g. Sunday, Monday). Use ddd to
display the three letter abbreviation of the day (e.g. Sun, Mon). Use dd to display the day
d
in two digits with a leading zero for single digit days (e.g. 09, 10). Use d to display the
day in digits (e.g. 9, 10).
Example
Note
The d, M, y expressions can be arranged in different order, but note the usage of uppercase “M”
for months as the lower case “m” is used for minutes.
Ordinal and Cardinal Formatting
Example
Ordinal values can also be converted to ordinal text with the \* OrdText switch.
Example
Example
The result will be in lower case but string format switch can be used to capitalize accordingly.
Values can be displayed as cardinal text with the \* DollarText switch. An ‘and’ will be inserted
at the decimal point and the first two decimals will be displayed over the 100 denominator.
Example
To format how time is displayed, use the date-time format switch \@.
Switch Description
Hours. Lower case h denotes 12-hour format and upper case H denotes 24-hour format.
h or H
Use hh or HH to display a leading zero on single digit hours.
m Minutes. Use mm to display a leading zero on single digit minutes.
s Seconds. Use ss to display a leading zero on single digit seconds.
AM/PM Displays AM or PM.
Example
Suppress the first five digits in a social security number stored in the TIN1 field formatted as
‘123-45-6789’.
Example
{QUOTE
Example
{QUOTE
Switch Description
\b Specifies text to be inserted before the merge field if the field is not blank
\f Specifies text to be inserted following the merge field if the field is not blank
Example
If all fields are not blank, the result will be Mary Jane Smith
Example
{MERGEFIELD street_address1}
{MERGEFIELD street_address2 \f "↲"}
{MERGEFIELD city}, {MERGEFIELD state} {MERGEFIELD zip}
Replace ↲ with an actual line break (Shift-Enter)
Without the \f switch, there would be an empty line between street_address1 and the
city/state/zip line.
Hyperlinks
If the field codes are not visible, press Alt+F9 to reveal the field codes. Select Insert > Quick
Parts > Field… and select Hyperlink. Uncheck the Preserve formatting during updates checkbox
and click OK.
Example
For email:
Place the insertion cursor after HYPERLINK and type "mailto: . Press Ctrl+F9 and enter
MERGEFIELD email then place a " after the closing } of the MERGEFIELD field.
Example
Place the insertion cursor between the last " and } then select Insert > Bookmark. Enter any name
for the bookmark and click Add. Nothing will appear in the document but this is an important
step as it prevents Word from altering the edited HYPERLINK field when the document is
closed.
Press Alt+F9 to hide the field code and the text for the hyperlink should read Error! Hyperlink
reference not valid.
To replace this with your own text, select Error! Hyperlink reference not valid leaving the period
at the end of the sentence unselected.
Enter any text to appear in place of the hyperlink, or to have the actual web address or email
address appear in its place, go to Insert > Quick Parts > Field….
Select MergeField and enter web_address or email in the Field name field. Uncheck the Preserve
formatting during updates checkbox and click OK.
Press the ⌦ delete key to delete the period that was left unselected previously.
Note
Do not replace or delete the entire Error! Hyperlink reference not valid. block of text at once as
this will break the merge field. Always leave at least one character untouched until after the edit
has been made.
Use caution when editing the HYPERLINK field at a later time as doing so could break its
functionality.