Mail Merge

S

shelly

I'm using Microsoft Word 2003. I have a paragraph that needs to change based
on a value given in the datasource. There are four different values with
four different responses. I found an example in help, where it used a
"nested if" statement, but it doesn't tell you where to place the statement
for it to run. I'm needing assistance in
1. Knowing where to place this complex "if" in the merged document to
run.(This is not a If...then..else)
2. Is there a better way to accomplish this task

Here is an example of the conditional paragraph.

{IF {letter_type} = "Basic Letter" "Bla."
"{IF {letter_type} = "Conditional Verbiage 1" "Bla Bla."}
"{IF {letter_type} = "Conditional Verbiage 2" "Bla, Bla, Bla."}
"{IF {letter_type} = "Conditional Verbiage 3" "Bla, Bla Bla Bla."}
"{IF {letter_type} = "Conditional Verbiage 4" "Bla, Bla, Bla, Bla, Bla."}"}
 
M

macropod

Hi Shelly,

The field coding you'd use could be expressed as:
{IF{MERGEFIELD letter_type}= "Type" "Text for letter type"}
or
{IF«letter_type»= "Type" "Text for letter type"}
where 'Type' represents each of your types (basic, conditions 1-4, etc).

If different letter types could be required at a particular location in the document, simply insert a field for each type at that
point, one after the other, in any order, for example:
{IF«letter_type»= "Type2" "Text for letter type 2"}{IF«letter_type»= "Type1" "Text for letter type 1"}{IF«letter_type»= "Type3"
"Text for letter type 3"}¶
where the '¶' is a paragraph mark or line-feed, depending on which you're using. It could even be more standard text that's part of
the same paragraph - the fields can be inserted anywhere you need them in a paragraph.

You only need the 'else' part of an IF statement if there is always an alternative output if a given letter type isn't present, for
example:
{IF«letter_type»= "Type1" "Text for letter type 1" "Text if not letter type 1"}
You might use this if a given letter type has one output and everything else has the same alternative output. Each true/false
expression can consist of multiple paragraphs too, if that helps.

If you have a situation in which everthing but a given letter type has an output, you can also use:
{IF«letter_type»= "Type1" "" "Text if not letter type 1"} or {IF«letter_type»<> "Type1" "Text if not letter type 1"}

Field nesting allows multiple alternatives, but doesn't appear to be required for what you've described.

Note: The field brace pairs (ie '{ }') for the above examples are created via Ctrl-F9 - you can't simply type them or copy & paste
them from this message. Likwise, you can't type the chevrons (ie '« »') - they're part of the actual mergefields, which you can
insert from the mailmerge toolbar Also bear in mind that the IF test is case-sensitive. If your data source has a variety of cases
for a given letter type, you could code the field as:
{IF{MERGEFIELD letter_type \* Upper}= "TYPE" "Text for letter type"}
where 'TYPE' is the upper-case represention each of your types .
 

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