Insert information from the Address Book into Word
Applies to Word 97 and above.
When you insert information from the Address Book into a Word document, the items of information and their page layout are pre-defined. Often, this is not appropriate. For example, you may want to include information such as a phone number, or you may want the surname followed by the first name.
One method of specifying the information that is extracted and its layout is to use a special AutoText entry called AddressLayout. The Microsoft Knowledge Base article number Q212345 explains how to do this for Word 2000, but the method also applies to Word 97.
A disadvantage with this method is that you can have only one format. Using the macro described here, you can define as many formats as you need by using a different macro for each format.
The macro is designed primarily to extract mailing information from Contacts in Microsoft Outlook. By default, when you select a name, the macro inserts the following:
Name (as displayed in the Address Book)
Job title
Company
Street (includes number, and may be more than one line)
City
Post code
If any of the information is missing, a blank line is inserted.
If you are competent with using the VBA macro editor in Word, you can easily customise the macro so that it inserts anything that is contained in the Address Book. For details, refer to the comments in the macro code.
Installation
Address.doc contains a macro project called InsertAddress. This project contains two macros.
- InsertCustomAddress. This is the macro that inserts the information into the Word file.
- AddCommandToInsertMenu. This is a supplementary macro that adds the Custom Address command to the end of the Insert menu in Word. It also adds an access key (underlined letter 'e').
To install the macros:
- Copy the macro project item called InsertAddress from Address.doc to your Normal (or other) template using the organiser (Tools, Templates and Add-ins, Organizer).
- Run the AddCommandToInsertMenu macro using the Macros dialogue box (Alt-F8).
Note: If you remove the macros from the template, the Custom Address command remains on the Insert menu in Word. To remove it, choose Tools, Customize. The Customize dialogue box appears. Whilst this is open, choose the Insert menu, and then drag the Custom Address entry off the list.
Using the macro
Note: if Microsoft Outlook is not open, then the Choose Profile dialogue box may appear the first time that you use the macro in a Word session.
To insert an address into a Word document:
- Choose Insert, Custom Address. The Address Book appears. (If no document is open, the macro does not run.)
- Select a name. The address details are inserted.
Downloads
address.doc, 29 KB.
address.bas, 4 KB. (This is the macro code as a text file which can be imported into the VBA editor.)