Our forums are currently in maintenance mode and the ability to post is disabled. We will be back up and running as soon as possible. Thanks for your patience!

General discussion


Mail Merging to Several Documents

By liz.lucero ·
I?m trying to create a mail merge that will merge with different letters depending on the code that is in the field named ?LETTERCODE?. I have 48 different letters and a database of 10,000 names. I would like to be able to do this automatically and not have to choose which names get which letter manually.

I am using MS Word 2002 on Windows 2000. My database is a Progress csv file that can be converted to Excel 2002.

I found this code in the MS Word Help files under ?If Statement?. I don?t know how to write the actual code that would do 48 if ? then ? else statements.
{ IF { MERGEFIELD LETTERCODE } = "1" "{ INCLUDETEXT G:\\worddocs\\contract.doc }"
{ IF { MERGEFIELD LETTERCODE } = "2" "{ INCLUDETEXT G:\\worddocs\\contract2.doc }"
{ IF { MERGEFIELD LETTERCODE } = "3" "{ INCLUDETEXT G:\\worddocs\\contract3.doc }"

I would like to have the exact code to accomplish this via a mail merge or a macro that I could run.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by DKlippert In reply to Mail Merging to Several D ...

I've done this before, it's pretty cool. The code is actually showing field indicators. It will be inserted into your main merge document. Your database will have a field that indicates what type of letter should be sent. That would be the REPORTTYPE or LETTERCODE
"Making your mail merge ?intelligent? by using IF fields" on the MS Word MVP website.

"At its simplest, an IF field works as follows: If a condition is met display one result, otherwise display another. A field of this sort would look a bit like this:

{ IF [Condition] [Display Result 1] [Display Result 2] }

Where the curly brackets represent field braces, which you must insert by pressing Ctrl+F9 (you can't type them). A real example might be:

{ IF { MERGEFIELD Gender } = "Male" "Him" "Her" }

Again, all of the curly brackets must be inserted by pressing Ctrl+F9."

Scroll down to hint 5:
"Inserting files at certain points in a document, depending on various conditions
You can combine IF fields MERGE fields and INCLUDETEXT fields into a single nested field to insert one of two (or more) files, depending on a flag you set in your Data Source, as follows:

{ IF { MERGEFIELD ReportType } = "PDD" { INCLUDETEXT I:\\Boilerplates\\PDD1.doc } { INCLUDETEXT I:\\Boilerplates\\Std1.doc } }

Let me know if you need more information.

Collapse -

by DKlippert In reply to

Here's a location with more merge information:

BTW ALT+F9 will toggle the Field codes to view and/or edit.

Collapse -

by liz.lucero In reply to

Thanks for your help. I've got it working now.

Collapse -

by liz.lucero In reply to Mail Merging to Several D ...

This question was closed by the author

Related Discussions

Related Forums