#1
|
|||
|
|||
Customize document content based on Mail Merge source fields?
I need help thinking through the best solution for some letters I need to create/mail merge. I'm comfortable with mail merge, and from poking around the forum this morning I think using an IF statement or something similar is possible, but that's not something I've done before and I'm not sure it's the solution to my problem.
I need to create letters to mail to individuals who are signed up to work various positions at various sites, and who will complete training on different days at different locations. The various positions and sites have different content (e.g., position description, directions to access a building, etc.). Instead of creating a multitude of base letters for these various situations, I'd like to automate this process (using mail merge?) So, something like if John's position field is "computer" the letter includes the 3 sentence description of that position. And if his work site is "library" it includes location details and a specific schedule of days and times (in a table if that will work, but I can reformat that if needed). And then if his training field is Oct 3, content about that training day is inserted. And then, of course, John's name and address for mailing. Even if you have general ideas about an approach, I can do some research on exactly how to execute this. I just figure there has to be a better way than creating a million different versions and only being able to mail merge the address block, but I'm not sure where to start. |
#2
|
||||
|
||||
Given the amount of text to insert and the possible numbers of options, I would suggest creating autotext entries with names that match exactly the values in the field names in question then insert autotext fields in your document e.g. { AUTOTEXT { MERGEFIELD Position } } and { AUTOTEXT { MERGEFIELD Site } } etc
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
Thank you!
I've never used autotext fields before, so I'm not sure I'm connecting all of the dots correctly. If one of the sites is "Library," I think what I would end up with after merging is something like { Library} Is that right? How do I get that to be replaced with the content of that autotext entry? I've tried Googling this for an hour or two but I'm not figuring it out. |
#4
|
|||
|
|||
AutoText and other Building Blocks get stored in templates. During a merge an AutoText entry named "MyEntry1" will get inserted if you have the text "myentry1" in a record with the fieldname ATname and bring it in through a merge.
{ AutoText { MergeField ATname } }. Such fields cannot be automatically created. You will need to do it by hand. Using Fields in Microsoft Word Ctrl+F9 creates a pair of the special field brace characters { }. You cannot just type them. |
#5
|
||||
|
||||
Quote:
{ AUTOTEXT { MERGEFIELD Site } } will insert the autotext 'Library' entry when Library is the value in that field in the record merged. The field is an Autotext field and the mergefield provides the value for the autotext field.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#6
|
||||
|
||||
The simplest solution might be to create a single document that contains all the letter variants (or, at least the content that differs), with each variant given a unique bookmark name - preferably a name that matches the output from a field in the datasource that is used to discriminate between the letters, then use an INCLUDETEXT field in the mailmerge main document with a suitable MEREGEFILED in the bookmark reference position. For example:
Code:
{QUOTE{INCLUDETEXT "{FILENAME \p}/../Variations Document.docx" "{MERGEFIELD Variant}"}}
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mail merge all fields into 1 document with rules | MP1989 | Mail Merge | 6 | 06-27-2018 04:43 PM |
Mail Merge Using Rules "IF" to add additional Text Based On Merge Field Content | Alfred | Mail Merge | 2 | 05-23-2017 10:59 PM |
Using 3 different fields, several times in same document but not en mass - should I use mail merge? | shoughton | Mail Merge | 1 | 06-24-2015 02:46 PM |
Merge fields in Word and source data from Excel | SteveVai | Mail Merge | 3 | 03-13-2014 05:25 AM |
dynamic charts based on mail merge fields | jwajehee | Mail Merge | 0 | 10-05-2011 09:47 AM |