Aspose.Words

Merge Field Formatting

If you want to format merged data, you need to format merge fields in the document as appropriate. Do not format the data in the data source because its formatting is not retained when you merge the data into the document.

This topic provides basic information about the merge field formatting. To learn the details, please refer to the Microsoft Word documentation.

Change Text Formatting

·          In the main document, select the field that contains the information you want to format, including the surrounding merge field characters («« »»).

·          On the Format menu, click a command, such as Font or Paragraph, and then select the desired options.

Change Capitalization

Merge fields in Microsoft Word support several options that affect how the data in the merge field is capitalized. Aspose.Words honors those options. You can set capitalization options in the Field dialog box in Microsoft Word.

Using Field Codes to Specify Formatting

Microsoft Word supports switches that control how numbers and dates are formatted and Aspose.Words honors those switches.

In Microsoft Word, press Alt+F9 to display field codes in the main document, and then add switches to the merge fields.

For example:

·          To display the number "34987.89" as "$34,987.89," add a numeric picture switch (\# $#,###.00).

·          To display the number "0945" as "9:45 PM," add the date/time picture switch (\@ "h:mm am/pm").

To ensure that the merged information has the same font and point size you apply to the merge field, add the \* MERGEFORMAT switch.

Please see the Microsoft Word documentation here to obtain more details about field switches.