M
Mike
I am trying to write a VBA program in Word that lists all
of the company names sorted in a list box using my
Outlook address book. When I use the sort statement I
recieve an error. What am I doing wrong in the following
code?
Dim objOutlook As Outlook.Application
Dim fdrContacts As Outlook.MAPIFolder
Dim itmContacts As Outlook.ContactItem
Set objOutlook = New Outlook.Application
Set fdrContacts = GetNamespace("MAPI").GetDefaultFolder _
(olFolderContacts)
For Each itmContacts In fdrContacts.Items.Sort _
("[ComapnyName]")
lstCompanyList.Additem itmContacts. _
ItemProperties(52).Value
Next
lstCompanyList is my ListBox
of the company names sorted in a list box using my
Outlook address book. When I use the sort statement I
recieve an error. What am I doing wrong in the following
code?
Dim objOutlook As Outlook.Application
Dim fdrContacts As Outlook.MAPIFolder
Dim itmContacts As Outlook.ContactItem
Set objOutlook = New Outlook.Application
Set fdrContacts = GetNamespace("MAPI").GetDefaultFolder _
(olFolderContacts)
For Each itmContacts In fdrContacts.Items.Sort _
("[ComapnyName]")
lstCompanyList.Additem itmContacts. _
ItemProperties(52).Value
Next
lstCompanyList is my ListBox