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 merge field formatting by adding format switches to the field codes. You can also apply all standard formatting (bold, italic, underline, etc.) to merge fields from Word's Format menu or toolbar.

General Text Formatting Options

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)

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 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)"}

Date and Time Formatting Options

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 codes is:

{MERGEFIELD FieldName \@ "Formatting Pattern"}

Date/Time Format Code

Description

Field Code Example

Output Example

Day

d

Displays the day of the 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 month as a number. Single digit day numbers will include a leading zero.

{MERGEFIELD Date \@ "dd 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. 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. 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