WD2000: How to Merge a Single Data Source to Multiple Letters with IncludeText (299837)



The information in this article applies to:

  • Microsoft Word 2000

This article was previously published under Q299837

SUMMARY

When you use the Mail Merge feature of Microsoft Word, you can use only one main document with one data source. However, with IF and AutoText fields, or IF and IncludeText fields, you can simulate merging one data source into several letters.

AutoText fields store your information in AutoText entries. IncludeText fields stores your information in separate letters. Both methods produce the same results.

This article describes how you can use the IncludeText fields to produce several letters using one data source.

For additional information about using the AutoText method instead, click the article number below to view the article in the Microsoft Knowledge Base:

211786 How to Merge a Single Data Source to Multiple Letters Using AutoText Entries

MORE INFORMATION

To merge a single data source to multiple letters using IncludeText fields, follow these steps.

Step 1: Set Up the Mail Merge Main Document

To create a mail merge to produce several different letters to different people based on a particular set of criteria, you must first create and save the separate letters that contain the merge fields you want to use.
  1. On the Tools menu, click Mail Merge.
  2. In the Main document section of the Mail Merge Helper dialog box, click Create, and then click Form Letters. In the next dialog box that appears, click Active Window.
  3. To use an existing data source, click Get Data, and then click Open Data Source. In the Open Data Source dialog box, find your data source, and then click Open.
  4. In the message box that appears, click Edit Main Document.
  5. Create the first letter. Enter the appropriate merge fields.
  6. On the File menu, click Save As, and then name the file. For example, type Letter1. Click Save.

    NOTE: You must know the path to this file; for example, if Letter1 is in the My Documents folder on the C drive, the path is C:\My Documents\Letter1.doc. You will need to enter this information in the main document created later.
  7. Change this letter as appropriate for the second letter. Enter merge fields as appropriate and save the file under a different name, such as Letter2.doc.
  8. Repeat steps 6 and 7 for each letter that you want to create. When you name the files, use distinct file names, such as "Letter2," "Letter3," and so on.

Step 2: Modify the Data Source

Once you create all of the letters as separate files, you need to modify your data source to include a field that will be helpful in identifying which letter you will create for a particular record. To do this, follow these steps:
  1. With the last mail merge letter that you created in the "Setting Up the Mail Merge Main Document" section earlier in this article, click Select All on the Edit menu, and then press DELETE to delete everything from the document.
  2. On the File menu, click Save As, give it a different file name, such as Main.doc, and then click Save.

    This document will become the mail merge main document that you will perform the merge from.
  3. On the Tools menu, click Mail Merge. Under Data Source, click Edit, and then click the name of the data file. The Data Form dialog box appears.
  4. Click View Source to view the data source in a table format.
  5. To create a new field, click the Manage Fields button on the Mail Merge toolbar.
  6. In the Field name box, type a field name (for example, type Code), click Add, and then click OK.
  7. Enter a code for each of the records to identify which letter will be used during the merge for that particular record. For example, if you created three letters, for each record in your data source, enter a 1, 2, or 3 in the Code field. Code 1 represents Letter1; Code 2 represents Letter2; Code 3 represents Letter3, and so on.
  8. Save the data file, and then click the Mail Merge Main Document button on the Mail Merge toolbar to return to the main document.

Step 3: Modify the Main Document

You need to modify the blank main document (Main.doc) to include IF fields that identify which IncludeText letter will be merged for each particular record.
  1. At the top of the blank document, follow these steps to enter an IF field into the document:
    1. Click the Insert Word Field button on the Mail Merge Toolbar.
    2. Click If... Then... Else....
    3. In the Field Name list, select the field that you created in the data source in the "Step 2: Modifying the Data Source" section earlier in this article (Code in the example in this article).
    4. In the Comparison list, click Equal to.
    5. In the Compare To box, type a value that you used in the newly created field (Code), such as 1, 2, or 3.
    6. Click OK. NOTE: If you do not see the field code instructions in the document, press ALT+F9 on the keyboard to turn on the field code view.

      If you used "Code" for the fieldname and typed in a value of 1, the field code in the document should look like the following:

      {IF {MERGEFIELD Code} = 1 "" ""}
    7. Click between the first set of two quotation marks, and then click Field on the Insert menu.
    8. Select the Links and References category, and then click IncludeText on the Field Names list.
    9. Click in the box that reads INCLUDETEXT, and then type the complete path and file name to the first letter. You must enclose the path in quotation marks and use double backslashes between each drive, directory, and file name.

      The finished field code looks similar to the following:

      {IF {MERGEFIELD Code} = 1 "{INCLUDETEXT "C:\\MY DOCUMENTS\\LETTER1.DOC" \*MERGEFORMAT}"}

      You can delete the second set of quotation marks. They are used for an Else condition that is not needed for this example.
  2. Select the complete IF field and copy it. Paste it in the document as many times as there are different letters with corresponding codes. For example, if there are three letters and three codes, paste the field so that there are three copies of it.
  3. In the pasted fields, modify the code used for the comparison value ( 1, 2, and so on) and modify the letter name to be used (Letter1.doc, Letter2.doc, and so on).

    If there are three different letters to be used in the merge, the main document looks similar to the following:
    {IF {MERGEFIELD Code} = 1 "{INCLUDETEXT "C:\\MY DOCUMENTS\\LETTER1.DOC" \*MERGEFORMAT}"}
    {IF {MERGEFIELD Code} = 2 "{INCLUDETEXT "C:\\MY DOCUMENTS\\LETTER2.DOC" \*MERGEFORMAT}"}
    {IF {MERGEFIELD Code} = 3 "{INCLUDETEXT "C:\\MY DOCUMENTS\\LETTER3.DOC" \*MERGEFORMAT}"}


  4. Save the main document.

Step 4: Merge the Documents

With the Main document open, click Mail Merge on the Tools menu, and then click Merge. Choose to merge to a New Document, and then verify that the correct letter is used for the appropriate records in your data source.

When you perform the mail merge, Word produces the letter based on the code the data file has for a particular record. For example, if Record 1 has a Code value of 1, Word produces Letter1. If record 2 has a Code value of 3, Word uses Letter3.

REFERENCES

For more information about mail merge, click Microsoft Word Help on the Help menu, type using mail merge in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbfield kbinfo kbmerge KB299837