View Single Post
  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default If the mergefield is blank, delete the line.

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

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


wrote:
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


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_lab...th_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

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




wrote:
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.