If the mergefield is blank, delete the line.

D

diane

I would like to print addresses. All of the addresses do not have the same
number of lines.

Name
Address 1
Address 2
City, State, Zip

Name
Address 1
City, State Zip

When Address 2 = N.A., I would like the merge to delete the line so the
address looks like the second example.
Many thanks.
 
G

Graham Mayor

You don't delete the line, but insert it only when it has content. Thus you
need to conditionally insert the field eg

{Mergefield Name}
{Mergefield Address1}{If{Mergefield Address2} <> "" "
{Mergefield Address2}"}
{Mergefield City} etc

You can use the same method for as many fields as may be empty.

Also if you use the old mailmerge helper -
http://www.gmayor.com/mail_merge_labels_with_word_xp.htm you should have
the option to suppress blank lines in addresses - but the former method is
simpler and more reliable.

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
D

diane

Thank you, Graham. I have inserted the line you suggested as follows:
«ADDRESS»} {If{Mergefield Street_Address_3} <> "" "
{Mergefield Street_Address_3}"}
«City_of_Residence»
«State_of_Residence_Code», «Zip_Code»

However, when I do the merge, this is what is happening:
268 Redding Road } {If{Mergefield Street_Address_3} <> "" "
{Mergefield Street_Address_3}"}
Atlanta

Can you tell me what I've done wrong?
Many thanks,
Diane
GA, 30319
 
G

Graham Mayor

You didn't use CTRL+F9 for the field boundarie pairs {}

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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