View Single Post
 
Old 01-27-2017, 02:46 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You can do this with one letter, using IF fields to vary the output as necessary. For example, such a field might be coded as:
{IF{MERGEFIELD State}= "AZ" "Text for Arizona"}{IF{MERGEFIELD State}= "CA" "Text for California"}, etc.
or:
{IF«State»= "AZ" "Text for Arizona"}{IF«State»= "CA" "Text for California"}, etc.

An individual IF field can contain anything from a single word to multiple paragraphs, tables & images, plus additional mergefields.

An alternative approach would be to have the entire text (and any additional mergefields) for each State in separate documents and use an INCLUDETEXT field to pull in the appropriate text. For example:
{IF{MERGEFIELD State}= "AZ" {INCLUDETEXT "C:\\FilePath\\Arizona.docx"}}{IF{MERGEFIELD State}= "CA" {INCLUDETEXT "C:\\FilePath\\California.docx"}, etc.
or:
{IF«State»= "AZ" {INCLUDETEXT "C:\\FilePath\\Arizona.docx"}}{IF«State»= "CA" {INCLUDETEXT "C:\\FilePath\\California.docx"}}, etc.

Taken to extremes, the mailmerge main document might contain just the IF fields.

Note: The field brace pairs (i.e. '{ }') for the above example 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 practical 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 'Insert Merge Field' dropdown. The spaces represented in the field construction are all required.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote