Display data in a combo box
Thanks Norman, it work perfect. I lost sleep on this!
can you please advise me how to add there address and telephone numbers
Many thanks again
Regards
Oggy
Norman Jones wrote:
Hi Oggy,
Try something like:
'=============
Private Sub UserForm_Initialize()
Dim olApp As Outlook.Application
Dim oContact As Outlook.ContactItem
Dim oContactFolder As Outlook.MAPIFolder
Dim oContactItems As Outlook.Items
Dim oNS As Outlook.NameSpace
Dim i As Long
Me.ComboBox1.Clear
On Error GoTo XIT
Set olApp = New Outlook.Application
Set oNS = olApp.GetNamespace("MAPI")
Set oContactFolder = oNS.GetDefaultFolder(olFolderContacts)
Set oContactItems = oContactFolder.Items
For i = 1 To oContactItems.Count
If oContactItems.Item(i).Class = olContact Then
Set oContact = oContactItems.Item(i)
Me.ComboBox1.AddItem oContact.FullName
End If
Next
Me.ComboBox1.ListIndex = 0
XIT:
Set oContact = Nothing
Set oContactItems = Nothing
Set oContactFolder = Nothing
Set oNS = Nothing
Set olApp = Nothing
End Sub
'<<=============
Set a reference to the Microsoft Outlook xx Object Library:
In the VBE,
Tools | References| Locate and select the library.
---
Regards,
Norman
"Oggy" wrote in message
oups.com...
I have a userform with a combo box, i am trying to get the combobox to
display external data from outlook, objcontacts. I have no idea how to
achieve this, please help.
|