Microsoft KB Archive/282595

From BetaArchive Wiki

Article ID: 282595

Article Last Modified on 9/25/2006



APPLIES TO

  • Microsoft Word 2002 Standard Edition



This article was previously published under Q282595


SYMPTOMS

In Microsoft Word 2002, when you record selecting recipients from Outlook contacts while you are using the Mail Merge Wizard, the macro recorder does not record this data source selection. As a result, when you run the recorded macro, either nothing happens or the resulting document is not linked to a data source.

If you record the additional actions of inserting merge fields and executing the mail merge, the recorded macro instead might result in the following Microsoft Visual Basic error message:

Run-time error '5852': Requested object is not available.

CAUSE

The Word 2002 macro recorder does not capture selecting recipients from Outlook contacts when you are using the Mail Merge task pane (also called the Mail Merge Wizard).

WORKAROUND

To work around this behavior, use one of the following methods.

Method 1: Use the "Mail Merge Use Address Book" Command

The Word 2002 macro recorder captures selection of the Outlook Address Book when you use the Mail Merge Use Address Book command.

To use this command, add the Mail Merge Use Address Book toolbar button by following these steps:

  1. On the Tools menu, click Customize.
  2. Select the Commands tab.
  3. In the Categories list, select All Commands.
  4. In the Commands list, scroll down until you find MailMergeUseAddressBook.
  5. Click this command to select it, and drag it from the Commands box onto one of the toolbars.
  6. Release the mouse button when you see a vertical bar, which indicates the position that you want for the button.

After you add the Mail Merge Use Address Book toolbar button, follow these steps to record the mail-merge macro:

  1. On the View menu, point to Toolbars, and then click Mail Merge.
  2. On the Tools menu, point to Letters and Mailings, and then click Mail Merge Wizard.
  3. On the Tools menu, point to Macro, and then click Record New Macro.
  4. Type a name for the new macro, and then click OK.
  5. Click the Main document setup button on the Mail Merge toolbar. By default, this is the leftmost button on the Mail Merge toolbar.
  6. Select the document type that you want, and then click OK.
  7. Click the Mail Merge Use Address Book button that you added in the steps earlier for adding the Mail Merge Use Address Book toolbar button.
  8. Select Outlook Address Book, and then click OK.
  9. Select Outlook Address Book via Converter (*.olk), and then click OK. NOTE: You see this dialog box only if the Confirm Conversion at Open check box is selected (on the Tools menu, click Options, and then click the General tab).


  1. In the Mail Merge Wizard, click Next: action, where action is the appropriate action for the document type that you selected in step 6 (for example, the action would be Write your letter if you selected Letters for the document type).
  2. Proceed with the mail merge by using the Mail Merge Wizard. Click the Stop Recording button when you complete all the actions that you want to record.

Method 2: Use the Mail Merge Helper

The Word 2002 macro recorder captures selection of the Outlook Address Book when you use the Mail Merge Helper dialog box, which is the default mail-merge dialog box in earlier Word versions.

To use the Mail Merge Helper in Word 2002, add the Mail Merge Helper toolbar button by following these steps:

  1. On the Tools menu, click Customize.
  2. Select the Commands tab.
  3. In the Categories list, select All Commands.
  4. In the Commands list, scroll down until you find MailMergeHelper.
  5. Click this command to select it, and drag it from the Commands box onto one of the toolbars.
  6. Release the mouse button when you see a vertical bar, which indicates the position that you want for the button.

After you add the Mail Merge Helper toolbar button, follow these steps to record the mail-merge macro:

  1. On the Tools menu, point to Macro and then click Record New Macro.
  2. Type a name for the new macro, and then click OK.
  3. Click the Mail Merge Helper button that you added in the steps earlier for adding the Mail Merge Helper toolbar button.
  4. Click Create and then click the document type that you want.
  5. Click Get Data and then click Use Address Book.
  6. Select Outlook Address Book, and then click OK.
  7. Select Outlook Address Book via Converter (*.olk), and then click OK.NOTE: You see this dialog box only if the Confirm Conversion at Open check box is selected (on the Tools menu, click Options, and then click the General tab).


  1. Do one of the following:
    • Click Edit Main Document if you selected Form Letters or Catalog (referred to as Directory elsewhere in Word 2002) as the document type.
    • Click Setup Main Document if you selected Mailing Labels or Envelopes as the document type.
  2. Edit or set up the document by using the steps appropriate for the document type that you selected (for example, if you selected Labels as the document type, choose the brand of label from the Label Options dialog box when it appears).
  3. Proceed with the mail merge, and then click the Stop Recording button when you complete all the actions that you want to record.

For additional information about using the Mail Merge Helper, click the article numbers below to view the articles in the Microsoft Knowledge Base:

212329 WD2000: How to Use Mail Merge to Create a Form Letter


212017 WD2000: How to Create Envelopes Using Mail Merge


212034 WD2000: How to Create Mailing Labels Using Mail Merge


Method 3: Edit the Macro in the Visual Basic Editor

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. For more information about how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:

290140 OFFXP: How to Run Sample Code from Knowledge Base Articles


Follow these steps to add an argument to the recorded macro that will select the Outlook Address Book:

  1. Select and copy (CTRL+C) the following Visual Basic argument:

    ActiveDocument.MailMerge.UseAddressBook Type:="olk"
                        
  2. On the Tools menu in Word 2002, point to Macro and then click Macros.
  3. In the Macros dialog box, select your recorded macro.
  4. With the recorded macro selected, click the Edit button.
  5. Place the insertion point in the macro where you want the data source selection to occur, and then press ENTER to add a new line.
  6. Paste the line of code that you copied in step 1 onto the new line.
  7. On the File menu, click Close and Return to Microsoft Word.


STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

REFERENCES

For additional information about mail merge, click the article numbers below to view the articles in the Microsoft Knowledge Base:

294697 WD2002: How to Use Outlook Contacts in a Word Mail Merge


290408 WD2002: Frequently Asked Questions About Mail Merge


For additional information about customizing toolbars in Word, click the article number below to view the article in the Microsoft Knowledge Base:

291292 WD2002: How to Work with Toolbars and Toolbar Buttons: Add, Create, Edit, Delete, Restore, and More



Additional query words: WD2002 VBE VBA mailmerge

Keywords: kbbug kberrmsg kbmerge kbpending KB282595