Solved

MS Word Mail Merge with If Then

Posted on 2011-02-23
8
365 Views
Last Modified: 2012-05-11
I can't figure out where my syntax is wrong.....

IF "{MERGEFIELD  CFO_name}" = ''"  "{MERGEFIELD managing_partner}" "{MERGEFIELD CFO_name}"

My result is: CFO_name}

If I use this:
IF "{ MERGEFIELD "CFO_name"}" = ''"  "{ MERGEFIELD "managing_partner"}" "{ MERGEFIELD "CFO_name"}"

my result is: CFO_name


Any help?
0
Comment
Question by:jasgot
  • 3
  • 3
  • 2
8 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 34964643
In the expanded field dispaly that we use, the {} pairs should actually be field delimiters and will appear slightly different on the actual document.

If you get an extra curly bracket after the data from the field CFO_Name in the result document, then it is likely to be that character, and not a field delimiter, because there is no delimiter that maps the start of the field (or at least you haven't shown it).

With that in mind, I suggest that you check the fields again. If you still have a problem, try reducing the document to the failing section and posting it here, so that we can have a look at it.

0
 

Author Comment

by:jasgot
ID: 34964800
The If statement above is what's inside the <ctrl>-<f9> brackets.  I'm not getting the field data followed by the curly, I'm getting "CFO_name}" in the resulting merge.

0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 34964837
Hello,

You are using to many quote marks. It should look like this

{IF { MERGEFIELD "CFO_name"} = ''"  "{ MERGEFIELD "managing_partner"}" "{ MERGEFIELD "CFO_name"}" }

No "" quote marks required in the condition (other than for the field name). The syntax is

{ IF condition "do when true" "do when false"}

cheers, teylyn
0
 

Author Comment

by:jasgot
ID: 34965057
teylyn;

if I press ctrl-F9 to get the sqiggly braces, then paste in your code without the beginning and ending braces, I get "MERGEFIELD" returned in my document.


0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 50

Accepted Solution

by:
Ingeborg Hawighorst earned 500 total points
ID: 34965184
Hello,

you can't just paste what I've posted. You need to enter each field with the Ctrl-F9 key. And I'm not too sure the "" are required for the mergefield names.

Step by step:

Hit Ctrl-F9
type IF between the brackets and add a space

should look like: {IF }

after the space hit Ctrl-F9 again

should look like: {IF {}}

Between these new brackets, enter
MERGEFIELD CFO_name

Should look like: {IF {MERGEFIELD CFO_name}}

click between the two closing brackets and enter
= ""

Should look like: {IF {MERGEFIELD CFO_name} = ""}

add a space and then two double quotes ""

Should look like: {IF {MERGEFIELD CFO_name} = "" ""}

put the cursor between the double quotes and hit Ctrl-F9

Should look like: {IF {MERGEFIELD CFO_name} = "" "{}"}

between the new pair of {} enter

MERGEFIELD managing_partner

Should look like: {IF {MERGEFIELD CFO_name} = "" "{MERGEFIELD managing_partner}"}

before the last closing bracket enter a space and two quotes ""

Should look like: {IF {MERGEFIELD CFO_name} = "" "{MERGEFIELD managing_partner}" ""}

click between the last two quotes and hit Ctrl-F9

Should look like: {IF {MERGEFIELD CFO_name} = "" "{MERGEFIELD managing_partner}" "{}"}

between the last pair of brackets enter

MERGEFIELD CFO_name

Should look like: {IF {MERGEFIELD CFO_name} = "" "{MERGEFIELD managing_partner}" "{MERGEFIELD CFO_name}"}

That's it.



0
 

Author Closing Comment

by:jasgot
ID: 34965279
Thanks! I appreciate your step by step! :)  My error was that I thought ON:Y the outsie curlies needed to be created by Ctrl-F9, I was using regular curlies for the iside fields :(

Thanks!
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 34965955
teylyn,

I gather that you are OK. Are you on the South Island?
0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 34966182
G, all fine, thx. I'm in Taranaki, north island
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now