Formatting Merge Fields |
When you create a merge field in Microsoft Word (see Creating a WordWriter Template), you can apply formatting to the field. For example, you can set a merge field's format to "Uppercase" to display the field's value in uppercase letters. WordWriter supports most text, date, and time formats available in Microsoft Word.
This section explains how to apply special merge field formatting. You can apply all standard formatting (bold, italic, underline, etc.) to merge fields from Word's Format menu or toolbar. |
The Field dialog opens when you add a new merge field to a template. To open the dialog for an existing merge field, right-click the field and select Edit Field...
The following text formatting options can be set within Microsoft Word's Field dialog, or by entering formatting codes within the merge field:
|
The Field Dialog in Microsoft Word 2002 (XP) |
WordWriter 1.0 does not support the following formatting options: Mapped field, Vertical formatting, and NumberedItem. |
To set a merge field's formatting to Uppercase, Lowercase, Title case, or First capital using the Field dialog:
To display text before and/or after a merge field value:
You can also set these formatting options by entering special codes in the merge field. To view and edit a merge field's field codes, right-click the field and select Toggle Field Codes. A field without special formatting looks like this:
{MERGEFIELD FieldName}
Format | Field Codes | Example |
---|---|---|
Uppercase | {MERGEFIELD FieldName \* Upper} | {MERGEFIELD ProductName \* Upper} |
Lowercase | {MERGEFIELD FieldName \* Lower} | {MERGEFIELD ProductName \* Lower} |
First capital | {MERGEFIELD FieldName \* FirstCap} | {MERGEFIELD ProductName \* FirstCap} |
Title case | {MERGEFIELD FieldName \* Caps} | {MERGEFIELD ProductName \* Caps} |
Text Before | {MERGEFIELD FieldName \b "Text to insert before"} | {MERGEFIELD OrderDate \b "Order Date: "} |
Text After | {MERGEFIELD FieldName \f "Text to insert after"} | {MERGEFIELD OrderDate \f " (Order Date)"} |
Using field codes, you can apply date/time formatting to merge fields that will bind to database fields of types Date, Time, and Timestamp, or to an object of type System.DateTime. The general format for applying date/time format codes is:
{MERGEFIELD FieldName \@ "Formatting Pattern"}
Date/Time Format Code | Description | Field Code Example | Output Example |
---|---|---|---|
Day | |||
d | Displays the day of the week or month as a number. Single digit day numbers will not include a leading zero. | {MERGEFIELD Date \@ "M/d/yyyy"} | 4/7/2003 |
dd | Displays the day of the week or month as a number. Single digit day numbers will include a leading zero. | {MERGEFIELD Date \@ "d MMMM yyyy"} | 07 April 2003 |
ddd | Displays a three-letter abbreviation for the day of the week. | {MERGEFIELD Date \@ "ddd, d-MMM-yy"} | Mon, 7-Apr-03 |
dddd | Displays the full name of the day of the week. | {MERGEFIELD Date \@ "dddd, MMMM d, yyyy"} | Monday, April 7, 2003 |
Month (Use uppercase M for months, lowercase m for minutes) | |||
M | Displays the month as a number. Single digit month numbers will not include a leading zero. | {MERGEFIELD Date \@ "M/d/yy"} | 4/7/03 |
MM | Displays the month as a number. Single digit month numbers will include a leading zero. | {MERGEFIELD Date \@ "yyyy-MM-dd"} | 2003-O4-07 |
MMM | Displays a three-letter month abbreviation. | {MERGEFIELD Date \@ "MMM-yy"} | Apr-03 |
MMMM | Displays the full month name | {MERGEFIELD Date \@ "MMMM d, yyyy"} | April 7, 2003 |
Year | |||
yy | Displays a two-digit year number. For years 1-9, the year number will include a leading zero. | {MERGEFIELD Date \@ "MMM-yy"} | Apr-03 |
yyyy | Displays a four digit year number | {MERGEFIELD Date \@ "MMMM d, yyyy"} | April 7, 2003 |
Hours | |||
h | Use lowercase h to display times based on the 12-hour clock. Lowercase h displays single-digit hours as single-digit numbers, without a leading zero. | {MERGEFIELD Time \@ "h:mm"} | 6:05 |
hh | Use lowercase hh to display times based on the 12-hour clock. Lowercase hh displays single-digit hours with a leading zero. | {MERGEFIELD Time \@ "hh:mm am/pm"} | 06:05 am |
H | Use uppercase H to display times based on the 24-hour clock (military clock). Uppercase H displays single-digit hours as single-digit numbers, without a leading zero. | {MERGEFIELD Time \@ "H:mm"} | 7:05 |
HH | Use uppercase HH to display times based on the 24-hour clock (military clock). Uppercase HH displays single-digit hours with a leading zero. | {MERGEFIELD Time \@ "HH:mm"} | 18:30 |
Minutes (Use lowercase m for minutes, uppercase M for months) | |||
m | Displays single-digit minutes without a leading zero. | {MERGEFIELD Time \@ "m 'minutes'"} | 2 minutes |
mm | Displays single-digit minutes with a leading zero. | {MERGEFIELD Time \@ "hh:mm am/pm"} | 06:05 am |
AM & PM | |||
AM/PM | Displays uppercase AM or PM. | {MERGEFIELD Time \@ "hh:mm AM/PM"} | 08:30 PM |
am/pm | Displays lowercase am or pm. | {MERGEFIELD Time \@ "hh:mm am/pm"} | 07:55 am |
Other Text | |||
'text' | To display text within a date or time, enclose the text in single quotation marks. | {MERGEFIELD Date \@ "hh:mm 'EST'"} | 06:15 EST |
character | To include a character, such as - (hyphen), in a date or time, do not enclose in quotation marks. | {MERGEFIELD Date \@ "MMM-yy"} | Apr-03 |
WordWriter 1.0 does not support the Microsoft Word following formatting options:
Copyright © 2003, SoftArtisans, Inc.