IF THEN ELSE Function in Mail Merge Doesn't Give The Option of <Field Name> CONTAINS

In the IF THEN ELSE mail merge function in Word 2013, I am not seeing an option to select Field Name CONTAINS a particular word or string of characters.  The only options in the drop down menu are:

Field Name Equal To

Field Name Not Equal To

Field Name Less Than

Field Name Greater Than

Field Name Less Than or Equal

Field Name Great Than or Equal

Field Name is Blank

Field Name is Not Blank

But there is no option that says Field Name CONTAINS.

For example, I want a certain word to be inserted into my document if the Field CONTAINS the expression "Haiti" anywhere in the Field. How do I get it to do that given that CONTAINS is not one of the drop down options?

Thanks!

JG

Answer
Answer

The reason you don't see a 'contains' option is because Word has no such field. That said, there are limited ways for testing whether a field contains something.

For example a field coded as:
{IF{MERGEFIELD MyField}= "MyText*" "True" "False"}
or:
{IF«MyField»= "MyText*" "True" "False"}
tests whether the results of the MERGEFIELD named MyField starts with 'MyText'
Similarly, a field coded as:
{IF{MERGEFIELD MyField}= "*MyText" "True" "False"}
or:
{IF«MyField»= "*MyText" "True" "False"}
tests whether the results of the MERGEFIELD named MyField ends with 'MyText'

You can also test whether the text you're interested in exists a pre-defined number of characters from the start or end. Thus, a field coded as:
{IF{MERGEFIELD MyField}= "???MyText*" "True" "False"}
or:
{IF«MyField»= "???MyText*" "True" "False"}
tests whether the results of the MERGEFIELD named MyField contains any three characters followed by 'MyText'
Similarly, a field coded as:
{IF{MERGEFIELD MyField}= "*MyText???" "True" "False"}
or:
{IF«MyField»= "*MyText???" "True" "False"}
tests whether the results of the MERGEFIELD named MyField ends with any three characters after 'MyText'

Note: The field brace pairs (i.e. '{ }') for the above example are 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)

8 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated April 13, 2024 Views 5,184 Applies to: