View Single Post
  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
 
Posts: n/a
Default Mail merge - Ask / If function

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


"Ian Rowe" Ian wrote in message
...
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