Outlook Connection

K

Kerry

I have created a user form which shows me a list of the
contacts I have in my Outlook account. Upon choosing a
contact the details are passed to variables which are
then used to address letters, labels etc.

The list of contacts are not showing in alphabetical
order, can anyone please advsie on how to sort this list?

Please find my code below, many thanks for your time:-

recipient:
x = 0
Set oApp = CreateObject("Outlook.Application")
Set oNspc = oApp.GetNamespace("MAPI")

For Each oItm In _
oNspc.GetDefaultFolder(olFolderContacts).Items

If oItm.Class = olContact Then 'no DL used
With Me.RecipList
.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
End If
Next oItm
 
J

Jean-Guy Marcil

Kerry was telling us:
Kerry nous racontait que :
I have created a user form which shows me a list of the
contacts I have in my Outlook account. Upon choosing a
contact the details are passed to variables which are
then used to address letters, labels etc.

The list of contacts are not showing in alphabetical
order, can anyone please advsie on how to sort this list?

Buld an array, sort the array and then load the box with the Array using the
List method.

Try this
http://word.mvps.org/faqs/macrosvba/SortArray.htm
or Google for "Sorting Arrays" and you will find plenty of examples.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
[email protected]
Word MVP site: http://www.word.mvps.org
 
Top