How to collect Address Book from Outlook

E

Eric

Hi,
I want to create a VBA Form which contain a combo box. When initial this form, all first name of outlook address book will be added into that combo box. After selected a name and clicked an OK button, I want to get name, address, company name, tel... values and print in Word document.
Can I do that? And how?
Thank you very much.
 
D

Doug Robbins - Word MVP

See
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dninvb00/html/ivb0076.asp

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
Eric said:
Hi,
I want to create a VBA Form which contain a combo box. When initial this
form, all first name of outlook address book will be added into that combo
box. After selected a name and clicked an OK button, I want to get name,
address, company name, tel... values and print in Word document.
 
E

Eric

I have read this before. But I cannot execut it because I got error when userform_initialization() of the following codes:

Private Sub UserForm_Initialize()
Dim oApp As Outlook.Application
Dim oNspc As NameSpace
Dim oItm As ContactItem
Dim x As Integer.......

What am I missing?
 
J

Jonathan West

Eric said:
I have read this before. But I cannot execut it because I got error when
userform_initialization() of the following codes:
Private Sub UserForm_Initialize()
Dim oApp As Outlook.Application
Dim oNspc As NameSpace
Dim oItm As ContactItem
Dim x As Integer.......

What am I missing?

Have you set a reference to Outlook in the Tools References dialog in the
VBA editor?
 
E

Eric

Thank you for your remind. I can run the codes now
But would you mind to teach me, how can I sort the contacts by LastName and show in the combo box
 
J

Jonathan West

Eric said:
Thank you for your remind. I can run the codes now.
But would you mind to teach me, how can I sort the contacts by LastName and show in the combo box?

Put the contacts into an array first, and then sort the array. There are
plenty of code samples available on the web for sorting. Do a search in
Google using the keywords "Quicksort" and "VB".

Once the array is sorted, you can assign the whole array to the List
property of the Combobox.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top