View Single Post
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
macropod[_2_] macropod[_2_] is offline
external usenet poster
 
Posts: 2,059
Default cannot print the first zero in a zip code.

Hi David,

You need to format the mailmerge field in Word to preserve the leading zeroes. If your zip codes are just the 5-digit form, you
could add a numeric picture switch to the mergefield. To do this:
.. select the field;
.. press Shift-F9 to reveal the field coding. It should look something like {MERGEFIELD ZipCode};
.. edit the field so that you get {MERGEFIELD ZipCode \# 00000};
.. position the cursor anywhere in this field and press F9 to update it;
.. run your mailmerge.

Otherwise, try the merge with the following field code. It correctly formats 5-digit and 5+4-digit zip code data, even where the
source data may have incorrect formatting such as a hyphen followed by trailing 0s after plain 5-digit zip codes or is formatted as
a numeric string without hyphens.
{QUOTE{SET Zip {MERGEFIELD ZipCode}}
{IF{Zip} 99999 {SET Zip {Zip \# "00000'-'0000"}}}
"{=-{=-{Zip}-Zip}/2 \# 00000;;}{=-({Zip}*(-1)-Zip)/2 \# ;-0000;}"}
or
{QUOTE{SET Zip «ZipCode»}
{IF{Zip} 99999 {SET Zip {Zip \# "00000'-'0000"}}}
"{=-{=-{Zip}-Zip}/2 \# 00000;;}{=-({Zip}*(-1)-Zip)/2 \# ;-0000;}"}

Notes:
1. The field brace pairs (ie '{ }') for the above examples are created via Ctrl-F9 - you can't simply type them or copy & paste them
from this message. Likwise, you can't type or copy & paste the chevrons (ie '« »') - they're part of the actual mergefields, which
you can insert from the mailmerge toolbar.
2. Although I've laid out the field codes in the 2nd & 3rd example with line feeds for readability, you can omit them if you prefer
3. The above examples also assume your zip code data are in a field named ZipCode - modify as need to suit your requirements.

--
Cheers
macropod
[Microsoft MVP - Word]


"David L" David wrote in message ...
Merging from excel into word. I cannot print the first zero in a zip code. I
have formatted the excel file to print zip codes before I proceed to merge.
when I complete the merge the first zero is not there.