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 Merge Randomly Drops Zip Code

Hi N,

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. A data field named €˜ZipCode is assumed.
{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 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]


"N" wrote in message ...
I am creating a merge for address labels in Word 2003, pulling from an Excel
2003 file. All rows in Excel are formatted the same with the zip code as
general and includes either 5 or 9 numbered codes. When I select my file
from Word and it opens the Mail Merge Recipients dialog box some fields show
a 0 instead of the zip code data. I've double checked the formatting and
changed it to number from general but it continues to occur. If I continue
with the merge those 0 fields transfer to the labels (City, ST, 0) and I am
left with random multiple addresses that are incomplete.

The list is 478 rows so going row by row to fix it for each dropped field
per label is very tedious and time consuming.

Any suggestions as to what I'm doing wrong? Thanks in advance.