Mail merge - Ask / If function

I

Ian Rowe

I have a mail merge document where I have created an 'Ask' function. When the
document is run, the ‘Ask’ function displays a question. I have used the 'If'
function so when the answer is inputted it will merge the relevant wording. I
can do this where there are two options/answers, but I need it to work for
four options. Is there an ‘If/Or’ function?

MS Office 2003
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?SWFuIFJvd2U=?=,
I have a mail merge document where I have created an 'Ask' function. When the
document is run, the ‘Ask’ function displays a question. I have used the 'If'
function so when the answer is inputted it will merge the relevant wording. I
can do this where there are two options/answers, but I need it to work for
four options. Is there an If/Or function?
No. What you have to do is either set up four separate IF fields (where the second
option is to display an empty string - "") or nest multiple IF fields. The first is
certainly simpler. The second would look something like this:
{ IF x = y "true" "{ IF x = z "true" { If x = a "true" "false" }" }" }

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in
the newsgroup and not by e-mail :)
 
P

Peter Jamieson

There are several ways to achieve this, none of them as obvious as you might
hope. Suppose your Ask field results in a bookmark called Option and you can
enter A,B,C or D as the option. Suppose if you have option A or C then you
want "text1", and if you have option B or D you want "text2"

Then you can spell out the possibilities

{ IF "{ Option }" = "A" "text1" ""
}{ IF "{ Option }" = "B" "text2" ""
}{ IF "{ Option }" = "C" "text1" ""
}{ IF "{ Option }" = "D" "text2" "" }

or you can nest them

{ IF "{ Option }" = "A" "text1"
"{ IF "{ Option }" = "B" "text2"
"{ IF "{ Option }" = "C" "text1"
"{ IF "{ Option }" = "D" "text2" "" }" }" }" }

To get something more like a traditional "or", you can use COMPARE fields
inside an { = } field, e.g.

{ COMPARE "{ Option }" = "A" }
returns 1 if Option is "A", 0 otherwise

{ =or({ COMPARE "{ Option }" = "A" },{ COMPARE "{ Option }" = "C" }) }
returns 1 if option is "A" or "C", 0 otherwise

so you can use
{ IF { =or({ COMPARE "{ Option }" = "A" },{ COMPARE "{ Option }" = "C" }) }
= 1
"text1" "text2" }

There are other ways you can use expressions in an { = } field to do this
kind of thing, and you ma also be able to arrange that the values of Option
you enter make it easier to do that.

Alternatively, you can use the option name to construct a file or bookmark
name for use in an INCLUDETEXT field, e.g.

{ INCLUDETEXT "c:\\mydata\\include{ Option }.doc" }

where includeA.doc and includeC.doc contain "text1" and so on

or put the text "text1" in a document called include.doc, bookmark it with
"bmA" and "bmC",
put the text "text2" in include.doc, bookmark it with "bmB" and "bmD"

and use

{ INCLUDETEXT "c:\\mydate\\include.doc" "bm{ Option }" }

In all these cases you must deal witht he case where Option is not A,B,C,D.

All the {} have to be the special field code braces you can enter using
ctrl-F9

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