Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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.

Info

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.

Anchor
text
text

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:

  • Uppercase
    Displays the merge field's value in uppercase letters.
  • Lowercase
    Displays the merge field's value in lowercase letters.
  • First capital
    Capitalizes the first letter of the first word in the field.
  • Title case
    Capitalizes the first letter of each word in the field.
  • Text Before
    Inserts a specified phrase before the merge field value.
  • Text After
    Inserts a specified phrase after the merge field value.


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:

  • The Field dialog opens automatically when you insert a new merge field. If you are formatting an existing merge field, right-click the merge field and select Edit Field...
  • From the Format list select a format. For example, select Uppercase.

To display text before and/or after a merge field value:

  • The Field dialog opens automatically when you insert a new merge field. If you are formatting an existing merge field, right-click the merge field and select Edit Field...
  • Check Text to be inserted before and/or Text to be inserted after.
  • In the Text Before text box, enter a phrase to display before the merge field value, and/or, in the Text After text box, enter a phrase to display after the 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:

Code Block
{MERGEFIELD FieldName}

Format

Field Codes

Example

Uppercase

Code Block
{MERGEFIELD _FieldName_ \\* Upper}
Code Block
{MERGEFIELD ProductName \\* Upper}

Lowercase

Code Block
{MERGEFIELD _FieldName_ \\* Lower}
Code Block
{MERGEFIELD ProductName \\* Lower}

First capital

Code Block
{MERGEFIELD _FieldName_ \\* FirstCap}
Code Block
{MERGEFIELD ProductName \\* FirstCap}

Title case

Code Block
{MERGEFIELD _FieldName_ \\* Caps}
Code Block
{MERGEFIELD ProductName \\* Caps}

Text Before

Code Block
{MERGEFIELD _FieldName_ \b "_Text to insert before_"}
Code Block
{MERGEFIELD OrderDate \b "Order Date: "}

Text After

Code Block
{MERGEFIELD _FieldName_ \f "_Text to insert after_"}
Code Block
{MERGEFIELD OrderDate \f " (Order Date)"}

Anchor
datetime
datetime

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:

Code Block
{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.

Code Block
{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.

Code Block
{MERGEFIELD Date \@ "dd MMMM yyyy"}

07 April 2003

ddd

Displays a three-letter abbreviation for the day of the week.

Code Block
{MERGEFIELD Date \@ "ddd, d-MMM-yy"}

Mon, 7-Apr-03

dddd

Displays the full name of the day of the week.

Code Block
{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.

Code Block
{MERGEFIELD Date \@ "M/d/yy"}

4/7/03

MM

Displays the month as a number. Single digit month numbers will include a leading zero.

Code Block
{MERGEFIELD Date \@ "yyyy-MM-dd"}

2003-O4-07

MMM

Displays a three-letter month abbreviation.

Code Block
{MERGEFIELD Date \@ "MMM-yy"}

Apr-03

MMMM

Displays the full month name

Code Block
{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.

Code Block
{MERGEFIELD Date \@ "MMM-yy"}

Apr-03

yyyy

Displays a four digit year number

Code Block
{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.

Code Block
{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.

Code Block
{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.

Code Block
{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.

Code Block
{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.

Code Block
{MERGEFIELD Time \@ "m 'minutes'"}

2 minutes

mm

Displays single-digit minutes with a leading zero.

Code Block
{MERGEFIELD Time \@ "hh:mm am/pm"}

06:05 am

AM & PM

AM/PM

Displays uppercase AM or PM.

Code Block
{MERGEFIELD Time \@ "hh:mm AM/PM"}

08:30 PM

am/pm

Displays lowercase am or pm.

Code Block
{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.

Code Block
{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.

Code Block
{MERGEFIELD Date \@ "MMM-yy"}

Apr-03