Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing fields from Outlook Address Book

Status
Not open for further replies.

Crazza

Technical User
Apr 20, 2000
11
EU
One of my users wishes to import fields from the Outlook 98 address book (contacts) into Word.<br><br>If you open the address book within Word and select one of the Contacts listed, it only inserts their name and address into the document. <br><br>Is there a way to set Word so that other fields can be picked up and inserted or will I have to resort to Visual Basic?<br><br>Thanks for the help<br><br>Craig Shepherd<br>Computer Manager<br>David Flatman Ltd<br><A HREF="mailto:craigs@flatman.co.uk">craigs@flatman.co.uk</A><br><br>
 
You can add this macro and modify it to suite your needs.<br>You will have to add Microsoft Outlook Object Library to your References. Review the help for the ContactItem object to get a complete list of information available. I just listed the name, company and phone in this case.<br><br>Sub ListAllContacts()<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim olApp As Object, olFolder As Object, olItems As Object<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim olThisOne As Object, olNameSpace<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;Set olApp = CreateObject(&quot;Outlook.Application&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;Set olNameSpace = olApp.GetNamespace(&quot;MAPI&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;Set olFolder = olNameSpace.GetDefaultFolder(olFolderContacts)<br>&nbsp;&nbsp;&nbsp;&nbsp;Set olItems = olFolder.Items<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;For Each olThisOne In olItems<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Selection.TypeText Text:=olThisOne.FullName<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Selection.TypeParagraph<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Selection.TypeText Text:=olThisOne.CompanyName<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Selection.TypeParagraph<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Selection.TypeText Text:=olThisOne.BusinessTelephoneNumber<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Selection.TypeParagraph<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Selection.TypeParagraph<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Selection.TypeText Text:=&quot;-----------------------------------------&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Selection.TypeParagraph<br>&nbsp;&nbsp;&nbsp;&nbsp;Next<br>End Sub<br><br>Hope this helps. Let me know if you need some more help.<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top