K
Kerry
I have created a Word User form which lists all of my
Outlook Contacts.
How can I sort the combo box - at the moment it is sorting
the names by the order in which they were created in
Outlook!!
Once this is sorted, my work is done!!
Thanks in advance.
Please find a copy of my code below:-
Private Sub UserForm_Initialize()
Dim oApp As Outlook.Application
Dim oNspc As NameSpace
Dim oItm As ContactItem
Dim x As Integer
Dim y As Integer
If Not DisplayStatusBar Then
DisplayStatusBar = True
End If
StatusBar = "Please Wait....."
sender:
x = 0
Set oApp = CreateObject("Outlook.Application")
Set oNspc = oApp.GetNamespace("MAPI")
For Each oItm In oNspc.GetDefaultFolder
(olFolderContacts).Items
With Me.cboContactList
.AddItem (oItm.FullName)
.Column(1, x) = oItm.JobTitle
.Column(2, x) = oItm.CompanyName
.Column(3, x) = oItm.BusinessAddress
.Column(4, x) = oItm.BusinessTelephoneNumber
.Column(5, x) = oItm.BusinessFaxNumber
End With
x = x + 1
Next oItm
StatusBar = ""
Set oItm = Nothing
Set oNspc = Nothing
Set oApp = Nothing
recipient:
y = 0
Set oApp = CreateObject("Outlook.Application")
Set oNspc = oApp.GetNamespace("MAPI")
For Each oItm In oNspc.GetDefaultFolder
(olFolderContacts).Items
With Me.cboContactList2
.AddItem (oItm.FullName)
.Column(1, y) = oItm.JobTitle
.Column(2, y) = oItm.CompanyName
.Column(3, y) = oItm.BusinessAddress
.Column(4, y) = oItm.BusinessTelephoneNumber
.Column(5, y) = oItm.BusinessFaxNumber
End With
y = y + 1
Next oItm
StatusBar = ""
Set oItm = Nothing
Set oNspc = Nothing
Set oApp = Nothing
End Sub
Outlook Contacts.
How can I sort the combo box - at the moment it is sorting
the names by the order in which they were created in
Outlook!!
Once this is sorted, my work is done!!
Thanks in advance.
Please find a copy of my code below:-
Private Sub UserForm_Initialize()
Dim oApp As Outlook.Application
Dim oNspc As NameSpace
Dim oItm As ContactItem
Dim x As Integer
Dim y As Integer
If Not DisplayStatusBar Then
DisplayStatusBar = True
End If
StatusBar = "Please Wait....."
sender:
x = 0
Set oApp = CreateObject("Outlook.Application")
Set oNspc = oApp.GetNamespace("MAPI")
For Each oItm In oNspc.GetDefaultFolder
(olFolderContacts).Items
With Me.cboContactList
.AddItem (oItm.FullName)
.Column(1, x) = oItm.JobTitle
.Column(2, x) = oItm.CompanyName
.Column(3, x) = oItm.BusinessAddress
.Column(4, x) = oItm.BusinessTelephoneNumber
.Column(5, x) = oItm.BusinessFaxNumber
End With
x = x + 1
Next oItm
StatusBar = ""
Set oItm = Nothing
Set oNspc = Nothing
Set oApp = Nothing
recipient:
y = 0
Set oApp = CreateObject("Outlook.Application")
Set oNspc = oApp.GetNamespace("MAPI")
For Each oItm In oNspc.GetDefaultFolder
(olFolderContacts).Items
With Me.cboContactList2
.AddItem (oItm.FullName)
.Column(1, y) = oItm.JobTitle
.Column(2, y) = oItm.CompanyName
.Column(3, y) = oItm.BusinessAddress
.Column(4, y) = oItm.BusinessTelephoneNumber
.Column(5, y) = oItm.BusinessFaxNumber
End With
y = y + 1
Next oItm
StatusBar = ""
Set oItm = Nothing
Set oNspc = Nothing
Set oApp = Nothing
End Sub