Barcode field inside "IF" Statement

L

LDanix

I am using Word and Excel to merge form letters and envelopes. The addresses
that I use go to the US and outside the US. I want Word to print the barcode
for US address and not generate an error message for non-US addresses. For
the life of me, I cannot figure out what is wrong with my syntax. I created a
column in Excel specifically to help the merge differentiate between what
needs a barcode and what does not. Here is my syntax for the field:

{ IF "{MERGEFIELD Country}" = "USA" "{BARCODE "{MERGEFIELD Street_Address}
{MERGEFIELD City_State_ZIP}"\*MERGEFORMAT}" ""}
 
D

Doug Robbins

I think that to get the barcode to display, the arguement for the Barcode
field should be

{ BARCODE \u {MERGEFIELD ZIP}}

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
G

Graham Mayor

Most of the correspondents in this newsgroup live outside the US, and thus
do not use barcodes; however fellow contributor Peter Jamieson wrote the
following a while back. The first sentence may provide a clue!:

"Ensure that your locale is set to U.S. English in Regional options,
otherwise the barcode field will not work whatever you do. (If you are in
the U.S. this would typically be the default setting).

US POSTNET barcodes are constructed from two pieces of information which you
will need in your data source:
a. a number in a street address
b. a 9-digit ZIP code

The BARCODE field requires that the 9-digit ZIP is in 5-4 format (with the
hyphen).

In your label you typically need a BARCODE field that looks like:

{ BARCODE "{ MERGEFIELD "street address" }¶
{ MERGEFIELD Postcodefield }" \u }

(The ¶ is just a normal paragraph mark that you will see if you press Enter
after { MERGEFIELD "street address" }
and click the ¶ symbol in Word's toolbar).

However, the last 2 digits of the BARCODE may not be generated from a Street
address in all
cases, so you may need to do something more than just { MERGEFIELD "street
address" }. You may find the following articles useful:

WD2000: How to Read Postal Bar Codes
http://support.microsoft.com/default.aspx?scid=kb;en-us;214181

and the article referenced in there:

WD2000: USPS Changes Postal Bar Code Requirements for Multi-Unit Buildings
http://support.microsoft.com/default.aspx?scid=kb;EN-US;220548

NB, The barcode field inserted by the Envelopes/Labels option uses a
slightly different approach which is to bookmark the whole address and use

{ BARCODE bookmarkname \b \u }

I would have also have a look at:

WD97: Word Assigns a Delivery Point Bar Code (DPBC) of 99:
http://support.microsoft.com/default.aspx?scid=kb;en-us;197008"


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
L

LDanix

If I take the barcode field out of the IF statement, and place it by itself,
it will generate a bar code just like it should. So, I know that all my
settings for the barcode to work are correct. If I remove the barcode field
and replace it with a couple words, in the IF statement, the IF statement
works as normal. I'm wondering if Word does not allow a barcode field to be
placed inside an IF statement, and if it is possible, what is the correct
syntax to get it to deliver the expected results.
 
G

Graham Mayor

I cannot see any mechanism that should prevent it from working, however it
may simply not be updating. Merge to a new document, select the lot (CTRL+A)
then press F9 to update. Does that improve things?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
P

Peter Jamieson

I see this problem in Word 2000, which is what is in front of me. Not sure
about other versions.

I suspect you may have to do something along the following lines:

Create another Word document and copy/paste your BARCODE field in
there.Select it, and insert a bookmark called USA. Then put the insertion
point somewhere outside the fieldand ensure it's a point selection (i.e.no
text isselected) and insert a bookmark called NONUSA.Save the document
(let's say it is called c:\barcode\barcode.doc) andput the following fields
in your mergemain document:

{ IF { MERGEFIELD Country } = "USA"
"{ SET barcodecountry USA }"
"{ SET barcodecountry NONUSA }"
}{ INCLUDETEXT "c:\\barcode\\barcode.doc" { REF barcodecountry } }

(Or if for example your data source has USA for the USA ones and NONUSA for
the others, you can avoid the IF and just try

{ INCLUDETEXT "c:\\barcode\\barcode.doc" { MERGEFIELD Country } }
)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top