K
Kerry
Hi
I have created a combo box (cboContactList)on a user form
which lists my contacts in outlook. However, the list is
sorted in the order in which the contacts were created
rather than in ascending alpha order - how can I change
this please.
Many thanks in advance.
Please find my user form initialize 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
I have created a combo box (cboContactList)on a user form
which lists my contacts in outlook. However, the list is
sorted in the order in which the contacts were created
rather than in ascending alpha order - how can I change
this please.
Many thanks in advance.
Please find my user form initialize 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