logo
search
Formatting Issues

Fix Unwanted Spaces in Word MERGEFIELD Number Formatting

Maira MehtabMaira Mehtab Sep 22, 2026 871 views

Question details

The user needs to remove unwanted spaces that appear in merged numerical values when using MERGEFIELD in a template, ensuring proper positive and negative number formatting.

Product
Word Processor
Device & OS
not provided
Scenario
Using a mail merge template (such as a Xero invoice template) containing numeric fields.
Observed behavior
The MERGEFIELD inserts unwanted spaces into positive and negative number formats, producing incorrect visual values such as 1,25 1.55.
Before you start

Ensure you have access to edit the field codes in your document template. You can easily toggle between displaying field codes and their results by pressing Alt + F9.

Solution 1Recommended

Use a Quoted Numeric Format Switch

Modify the MERGEFIELD code to include a specific numeric switch that explicitly defines the formatting pattern without spaces.

Unwanted spaces usually appear when the default formatting from the data source clashes with the document's locale settings, or when formatting switches are applied with loose spacing. Applying a strict, quoted numeric picture switch forces the word processor to format the number exactly as defined.

1
Toggle field codes

Right-click the problematic merged field and select 'Toggle Field Codes', or simply select the field and press Shift + F9 to reveal the underlying code.

2
Edit the field code switch

Locate the specific field (for example, {MERGEFIELD TaxInclusiveUnitAmount}) and append the format switch exactly as follows: \# "#,##0.00;(#,##0.00)". Make sure there are no spaces after the comma inside the quotes.

3
Update the field

Select the entire edited field code and press F9 on your keyboard. This forces the document to refresh the field and display the correctly formatted numerical result.

Understanding the numeric switch: In the switch \# "#,##0.00;(#,##0.00)", the segment before the semicolon defines the format for positive numbers, while the segment inside the parentheses defines the format for negative numbers.
Efficient Mail Merge

Seamlessly Format Mail Merge Fields in WPS Writer

WPS Writer provides robust mail merge capabilities, allowing you to easily insert, edit, and format field codes like MERGEFIELD. You can effortlessly manage number, date, and text formatting for your invoices, letters, and customized templates.

  1. 1. Open your template: Launch WPS Writer and open your mail merge template document.
  2. 2. Access field codes: Right-click on the specific field you want to modify and select 'Toggle Field Codes' from the context menu.
  3. 3. Apply formatting: Add your required numeric formatting switch, such as \# "#,##0.00", to the end of the field name.
  4. 4. Refresh results: Select the field and press the F9 key to instantly update the formatting and preview the result.
Full support for Microsoft Word field codes and formatting switches100% compatible with Microsoft Word DOCX and DOC file formatsIntuitive Mail Merge interface for quick document generationLightweight application that runs smoothly on all PCs
microsoft office alternative - wps office

Frequently Asked Questions

Why does my MERGEFIELD show unformatted raw numbers?

By default, the Mail Merge function pulls raw, unformatted data straight from the data source (like Excel or a database). To display it correctly in your document, you must apply specific formatting switches like \# for numbers or \@ for dates within the field code.

How do I view all field codes in my document at once?

You can press Alt + F9 on your keyboard to toggle the display between the field results and the underlying field codes for the entire document simultaneously.

Can I format currency using a MERGEFIELD switch?

Yes, you can add a currency symbol directly into the switch. For example, updating your code to {MERGEFIELD Amount \# "$#,##0.00"} will display the number with a dollar sign and standard comma separators.

Why doesn't my field update automatically after I change the code?

Word processors generally do not refresh field codes live in order to save system resources. Whenever you modify a field code, you must manually force an update by selecting the field and pressing the F9 key, or by right-clicking and selecting 'Update Field'.