View Single Post
  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
macropod[_2_] macropod[_2_] is offline
external usenet poster
 
Posts: 2,059
Default How to format Zip Code from 9 to 5

Hi Doug,

Your mission, if you choose to accept it, is to figure out how the code works ...

--
Cheers
macropod
[MVP - Microsoft Word]


"Doug Robbins - Word MVP on news.microsoft.com" wrote in message
...
I should have known that you would come up with a way of doing it.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"macropod" wrote in message ...
Hi Leslie,

You can eliminate the unwanted portions via a field coded as:
{QUOTE{SET ID {MERGEFIELD ZipCode}}{SET EXP1{=-{=-{ID}-ID}/2}}{EXP1}}
Where 'ZipCode' is the name of the data field containing your Zip Codes.

With this coding, any of 75043-0000 or 75043--000 or 75043-000 will be returned as 75043.

Note: The field brace pairs (ie '{ }') for the above example are created via Ctrl-F9 - you can't simply type them or copy & paste
them from this message.

--
Cheers
macropod
[MVP - Microsoft Word]


"Leslie" wrote in message ...
I hope this makes sense! We have a glitch in our computer software that
automatically places zeros in the place of the zip code plus 4 numbers when
there are no numbers there, 75043-0000 or 75043--000 or 75043-000. Since we
do not have control over programming we need to overcome this problem,
hopefully, by using MS Word. We are okay with not seeing the plus four
numbers if they are there, because most often we only get the standard 5
numbers.

I have tried different formatting using Bookmarks, and this works if there
are only zeros in the plus 4 field, but if there ARE numbers what I get is
Word subtracting the plus four and creating a whole new zip code.

{IF {ZIP} 99999 "{ ZIP \# "00000'-'0000"}""{ZIP \# "00000"}"}
takes this number 75841-1111 and makes it 74730.

Is there any way to get Word to just truncate the last four numbers and only
show the first five?