Applies ToWord for Microsoft 365 Word 2024 Word 2021 Word 2019 Word 2016

Displays the name of a data field within the "chevron" merge characters in a mail merge main document — for example, «FirstName». When the main document is merged with the selected data source, information from the specified data field is inserted in place of the merge field.

In previous versions of Word, merged documents frequently displayed double spaces in place of field that mapped to missing data. Now you can use switches to specify which text is printed before or after the field results (provided that the field contains data).

You must select the data source for the main document before you insert merge fields.

Syntax

When you view the MergeField field in your document, the syntax looks like this:

{ MERGEFIELD FieldName [Switches]}

Note:  A field code tells the field what to show. Field results are what’s shown in the document after having evaluated the field code. To toggle between viewing the field code and the field code results, press Alt+F9.

Instructions

"FieldName"

The name of a data field listed in the header record of the selected data source. The field name must exactly match the field name in the header record.

Switches

\b

Specifies the text to be inserted before the MergeField field if the field is not blank.

\f

Specifies the text to be inserted following the MergeField field if the field is not blank.

\m

Specifies that the MergeField field is a mapped field.

\v

Enables character conversion for vertical formatting.

Example

Placing the following three MergeField fields together and using the \f switch as specified ensures that the three fields have spaces between them, but only if the designated field information is present in the data source.

{ MERGEFIELD CoutesyTitle \f " " }{ MERGEFIELD FirstName \f " " }{ MERGEFIELD LastName }

Results in the following:

  • If all fields are present: Ms. Mindy Martin

  • If FirstName is missing from the data source: Ms. Martin

Note: If you need to change the field name specified in a merge field, edit the field name in the MergeField field codes. Changing a field name with the field codes hidden has no effect.

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.