Tuesday, May 3, 2011

Formatting problem - How can I format zip code merge field to add hyphen if zip + 4?

Another great question inspired a deeper look into formatting Word Fields when working in a mail merge document.  Google is my friend and a found a site or two for assistance, but pictures speak louder than words, so here is my attempt to clarify how to accomplish the task.

You can format the contents of a field  inserted into a document, using a "switch" Alt + F9 will allow you to edit a manually inserted merged field and Ctrl + F9 will insert Field Boundaries { } needed to convert/change the merge field.

Senerio:  Your data source, in Excel the zip codes are either 5 or 9 digits.  Formatting the cells to add the hyphen (Format cells-->Special-->Zip+4) appears to correct the issue but a closer look at the formula bar reveals numbers only with no hyphen.  For a mail merge document using this data source the zip code will not have a hyphen in the mailing address field. 





Applying a number format that will convert all ZIP codes to ZIP + four format.  i.e., 451253589 will be changed to 45125-3589. Using a conditional field will apply appropriate formats even if the field has five or nine digits.  So lets give this a try...

1. Manually adding an address fields to letter/labels will show what a merged field looks like, previewing displays the zip code without formatting.



















2.  Press Alt + F9- allowing for conditional formatting, click within and at the beginning of the MERGEFIELD Zip field and press Ctrl + F9** field boundaries have to be inserted not typed from keyboard, using Ctrl + F9 is the correct way to insert { }(field boundaries). 







 3.  Enter:




4.  Press Alt + F9 and preview letters/labels resulting in the formatting of a hyphen for the zip code field.

Additionally, if you wish the + 4 not to appear then use the following switch when formatting the field:




Feedback appreciated, let me know how it worked -RS

Other Web Resources:

Formatting Word Fields: http://www.gmayor.com/formatting_word_fields.htm

MS Office Forums: http://www.msofficeforums.com/mail-merge/6804-adding-dash-middle-my-field.html

No comments:

Post a Comment