If, else...

I am creating a mail merge for resumes and I want a section to collapse/disappear if it does not populate with data...can I do that? 

I am working with Microsoft Word 2010

Answer
Answer

You can use an IF test coded along the lines of:

{IF{MERGEFIELD MyField}<> "" "Variable text"}

or

{IF«MyField»<> "" "Variable text"}

where 'MyField' is a field in the data source that determines whether the variable text is to be displayed. The variable text can include multiple paragraphs, tables & pictures if need be.

In the above example, it is assumed you want nothing displayed if 'MyField' is empty. Changing the '<>' to '=' inverts the test. Thus, if you only want the variable text to display if 'MyField' has a specified value (e.g. 'MyValue'), you could use a field coded like:

{IF{MERGEFIELD MyField}= "MyValue" "Variable text"}

or:

{IF«MyField»= "MyValue" "Variable text"}

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)

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 October 5, 2021 Views 70 Applies to: