Document Editing Problems

Suppress Spaces in Empty Word Mail Merge Address Fields

Amos GikundaAmos Gikunda Nov 22, 2026 868 views

Question details

Make address separators appear only when their corresponding Word mail merge fields contain data.

Product
Microsoft Word Mail Merge
Device & OS
not provided
Scenario
A mail merge uses several street address fields and P.O. Box fields for records with different address formats.
Observed behavior
Records with a P.O. Box can show unwanted leading spaces when preceding street address fields are empty.
Before you start

Open the Word mail merge main document and confirm that it is connected to the intended recipient list. Use Mailings > Preview Results to find a record with a P.O. Box and empty street address fields for testing.

Solution 1Recommended

Make Word address field separators conditional

Use the mail merge field's \f switch to add a space or line break only when that field contains data.

The \f switch inserts the quoted text after a merge field only when the field is not blank. For example, { MERGEFIELD Street1 \f " " } adds a space after Street1 only when Street1 has a value.

1
Show field codes

In the mail merge document, press Alt+F9 in Word for Windows to display the merge field codes. Alternatively, right-click an individual merge field and choose Toggle Field Codes.

2
Add conditional separators

Inside each relevant address field code, add \f followed by a quoted separator before the closing field brace. For fields that should be followed by a line break, put a carriage return inside the quotation marks. Apply the switch to the street address fields and the first P.O. Box field where a separator is needed.

3
Remove fixed separators

In the address block, remove existing spaces or paragraph breaks that would duplicate the conditional separators. Keep any separators that should always appear.

4
Preview different records

Press Alt+F9 again to hide the field codes, then select Mailings > Preview Results. Use the record navigation buttons to check a P.O. Box record and a street address record.

Make Word address field separators conditional
Choose the right separator: Use a quoted space for fields on the same line and a carriage return inside the quotes when the next populated field should start on a new line. Adjust the separators to match the intended address layout.
Free Microsoft Office alternative

Edit Address Documents with WPS Writer

WPS Office is a free, lightweight alternative with a familiar interface for opening and editing Word documents. Its format compatibility helps you move existing documents into WPS, although it does not repair Microsoft Word's mail merge field behavior.

Create and edit address documents in WPS WriterOpen and save Microsoft Word DOC and DOCX filesWork in a familiar, easy-to-use interfaceMove existing Office documents into a lightweight suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does a P.O. Box address start with spaces?

The spaces may be fixed separators between merge fields. If earlier street address fields are empty, those separators can remain before the P.O. Box. Make each separator conditional using the preceding field's \f switch.

How do I see the merge field codes in Word?

In Word for Windows, press Alt+F9 to show or hide all field codes. You can also right-click an individual field and select Toggle Field Codes.

Can I add a line break only when an address field has a value?

Yes. Add the \f switch to that merge field and place a carriage return inside the quoted text. Remove any separate fixed line break that would duplicate it, then check the result under Mailings > Preview Results.

How can I check that the address works for every recipient?

Select Mailings > Preview Results and use the record navigation buttons to review records with different combinations of street address and P.O. Box fields.