Solved

MS Word Mail Merge with If Then

Posted on 2011-02-23
8
364 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:teylyn
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 50

Accepted Solution

by:
teylyn 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:teylyn
ID: 34966182
G, all fine, thx. I'm in Taranaki, north island
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.

762 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

23 Experts available now in Live!

Get 1:1 Help Now