Solved

MS Word Mail Merge with If Then

Posted on 2011-02-23
8
368 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

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
 
LVL 50

Accepted Solution

by:
Ingeborg Hawighorst (Microsoft MVP / EE MVE) 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
ID: 34966182
G, all fine, thx. I'm in Taranaki, north island
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

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 walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…

734 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