logo
search
Formatting Issues

How to Format Five and Nine-Digit ZIP Codes in Word Mail Merge

Khadija KhanKhadija Khan Oct 9, 2026 872 views

Question details

The user needs to format ZIP codes dynamically in a Word mail merge so that five-digit codes appear normally and nine-digit codes include a hyphen, without modifying the original Excel data.

How to Format Five- and Nine-Digit ZIP Codes in Word Mail Merge
Product
Microsoft Word / WPS Writer
Device & OS
not provided
Scenario
Performing a document mail merge using an Excel spreadsheet that contains a mix of five-digit and nine-digit ZIP codes.
Observed behavior
Five-digit ZIP codes must display as 12345 and nine-digit codes must display as 12345-6789 automatically upon merging.
Before you start

Ensure your Excel source data contains the raw numerical ZIP codes in a single column and is successfully linked to your Word document for the mail merge.

Solution 1Recommended

Use If...Then...Else Rules in Word Mail Merge

Set up conditional rules in your mail merge document to automatically format ZIP codes based on their numerical value.

This is the most effective Word-only solution. It allows you to dynamically format the ZIP codes during the merge process without altering your original Excel source workbook.

1
Navigate to Mailings Rules

Go to the Mailings tab in Word. Ensure your Excel recipient list is already selected, then click on 'Rules' and select 'If...Then...Else' from the dropdown menu.

2
Configure the Condition

Under 'Field name', select your ZIP Code merge field. Change the 'Comparison' to 'Greater than' and type '99999' in the 'Compare to' box.

3
Insert Field Codes for 9-Digit ZIPs

In the 'Insert this text' box, use Ctrl+F9 to insert the required field braces and type the specific merge field code formatting for nine-digit codes (e.g., adding a hyphen).

4
Configure the 5-Digit Fallback

For the 'Otherwise insert this text' result, simply insert the standard ZIP Code merge field so that five-digit codes display as standard 12345.

Use If...Then...Else Rules in Word Mail Merge
Dynamic Formatting: This conditional rule accurately parses five-digit ZIP codes as 12345 and nine-digit codes as 12345-6789 automatically when you preview or complete the merge.
Efficient Mail Merge Solutions

Seamlessly Format Mail Merge Fields with WPS Writer

WPS Writer offers a comprehensive, highly compatible Mail Merge feature that fully supports Excel data sources and custom field codes. You can effortlessly handle mixed ZIP codes, conditional rules, and formatting tasks in a streamlined interface.

  1. 1. Launch WPS Writer: Open WPS Office and start a new document or open your existing mailing template.
  2. 2. Import Excel Data: Navigate to the 'Mailings' tab, click 'Open Data Source', and select your Excel spreadsheet containing the ZIP code records.
  3. 3. Apply Conditional Rules: Insert your merge fields and use the 'Rules' function to easily set an If...Then...Else condition for >99999 values.
  4. 4. Preview Merged Data: Click 'View Merged Data' to instantly verify that both your five-digit and nine-digit ZIP codes display with correct hyphenation.
Advanced Mail Merge features fully compatible with Excel data sourcesRobust support for conditional rules (If...Then...Else) and field code formattingSeamless 100% format compatibility with Microsoft Word (.docx)Free, lightweight, and features a familiar user interface for quick adoption
microsoft office alternative - wps office

Frequently Asked Questions

Why are leading zeros disappearing from my ZIP codes during the mail merge?

Excel often treats ZIP codes as numbers by default and drops leading zeros (e.g., 01234 becomes 1234). You can fix this by adding a numeric picture switch like \# "00000" to your merge field in Word, or by pre-formatting the column as Text in your Excel spreadsheet.

How do I edit existing mail merge field codes in my document?

You can press Alt+F9 (or Option+F9 on Mac) to reveal the hidden field codes in your document. You can then manually edit the rules, spacing, or formatting switches before pressing Alt+F9 again to hide them and return to standard view.

Is there a way to format ZIP+4 codes directly in Excel without using Word rules?

Yes. In Excel, select the ZIP code column, right-click, and choose 'Format Cells'. Go to the 'Special' category and select 'Zip Code + 4'. Keep in mind that depending on your Word connection method (like DDE vs OLEDB), you may still need to adjust formatting in Word.