#1
|
|||
|
|||
Mail Merge IF-THEN-ELSE rule
Is it possible to include an "OR" in an IF-THEN-ELSE rule for a mail merge letter? I want to do something like this:
IF mergefield A is blank OR mergefield B = "No" THEN "xx" ELSE "yy" Any help with code for this much appreciated! |
#2
|
||||
|
||||
You can build quite complex AND & OR tests with field coding.
For AND tests you can use field coding like: {IF{={IF{MERGEFIELD Field1}= Y 1 0}*{IF{MERGEFIELD Field2}= "" 1 0}}= 1 "True Text" "False Text"} {IF{={IF{MERGEFIELD Field1}= Y 1 0}*{IF{MERGEFIELD Field2}= "" 1 0}*{IF{MERGEFIELD Field3}= "" 1 0}}= 1 "True Text" "False Text"} etc. or: {IF{={IF«Field1»= Y 1 0}*{IF«Field2»= "" 1 0}}= 1 "True Text" "False Text"} {IF{={IF«Field1»= Y 1 0}*{IF«Field2»= "" 1 0}*{IF«Field3»= "" 1 0}}= 1 "True Text" "False Text"} etc. For OR tests you can use field coding like: {IF{={IF{MERGEFIELD Field1}= Y 1 0}+{IF{MERGEFIELD Field2}= "" 1 0}}> 0 "True Text" "False Text"} {IF{={IF{MERGEFIELD Field1}= Y 1 0}+{IF{MERGEFIELD Field2}= "" 1 0}+{IF{MERGEFIELD Field3}= "" 1 0}}> 0 "True Text" "False Text"} etc. or: {IF{={IF«Field1»= Y 1 0}+{IF«Field2»= "" 1 0}}> 0 "True Text" "False Text"} {IF{={IF«Field1»= Y 1 0}+{IF«Field2»= "" 1 0}+{IF«Field3»= "" 1 0}}> 0 "True Text" "False Text"} etc. With the OR tests, changing the final 0 to another number can be used to specify that more than one condition must be met. Setting it to the same as the number of IF tests turns it into an AND test. With care, you can also combine the AND & OR tests. Note: The field brace pairs (i.e. '{ }') for the above examples are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practicable to add them via any of the standard Word dialogues. Likewise, you can't type or copy & paste the chevrons (i.e. '« »') - they're part of the actual mergefields, which you can insert from the mailmerge toolbar. The spaces represented in the field construction are all required.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
mail merge help, mail merge issue, mail merge; if; fill-in |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mail Merge in Word: creating a rule for blanks | cgranada | Mail Merge | 6 | 02-27-2017 09:08 AM |
Problem with delay outgoing mail rule | maverick1714 | Outlook | 0 | 09-30-2014 12:15 AM |
Mail merge how to link mail merge field value to a column heading | dsummers | Mail Merge | 1 | 05-08-2014 02:59 PM |
Rule for reading notification E-Mail | balubeto | Outlook | 2 | 07-27-2012 10:47 AM |
modifying rule to show new mail envelope in task bar | mlov83 | Outlook | 5 | 02-11-2011 01:36 PM |