Conditionally print outlook company in mail merge

S

Stukmeister

I am using MS Outlook Contacts with MS Word to mail merge envelopes. I need
to print the Company name line if the "Mailing Address" is a business
address. If the "Mailing Address" is a home address, I don't want to print
the Company name line.

A potential programatic solution would be: If MailingAddress =
BusinessAddress then print Company address line, else don't print Company
address line. I just don't know how to code it in Word.

Anyone know how to solve this?
 
P

Peter Jamieson

First, to do this, you must be using the individual address fields, not the
ADDRESSBLOCK field.

Then, to do what you said, you need something like

{ IF "{ MERGEFIELD "Mailing_Address" }" = "{ MERGEFIELD
"Business_Address" }" "{ MERGEFIELD "Business_Address_Street" } "" }

but I wonder if you actually need:

{ IF "{ MERGEFIELD "Mailing_Address" }" = "{ MERGEFIELD
"Business_Address" }" "{ MERGEFIELD "Company" } "" }

To insert these nested fields, use ctrl-F9 to insert the pairs of special
field braces {}, and type everything else in between. There are other ways
to do it, but I think that's the most straightforward.

To do either of those, you will probably need to initiate your merge from
Outlook, because you may not get the same fields if you connect using the
Outlook Contacts option in the Word Merge Wizard.

Peter Jamieson
 
S

Stukmeister

This works fine except that I also don't want to print the "Company" line of
the address if the mailing address and business address are not the same. The
way it is now, it prints a blank line in the address.
 
P

Peter Jamieson

As long as the comparison does what you need, it's then up to you what you
put in the "results", e.g.

{ IF "{ MERGEFIELD "Mailing_Address" }" = "{ MERGEFIELD
"Business_Address" }"
"{ MERGEFIELD "Company" }
{ MERGEFIELD "Mailing_Address" }"
"{ Mergefield "Mailing_Address_Street" }
whatever else you need" }

or whatever. If you want to suppress blank lines that occur as a result of
the IF field, in Word 2002/2003 you have do a bit more - ask if that's what
you need, or search this newsgroup as this question comes up quite
frequently.

Peter Jamieson
 

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