O
Office_Novice
This Works great if I want everything. However I only want the names in a
specific Distribution List. Is there a way to break this down to that level?
Option Explicit
Public Sub DisplayOutlookContactNames()
Dim Outlook As Outlook.Application
Dim NameSpace As Outlook.NameSpace
Dim AddressList As AddressList
Dim Entry As AddressEntry
Dim I As Long
On Error GoTo Finally
Set Outlook = New Outlook.Application
Set NameSpace = Outlook.GetNamespace("MAPI")
Set AddressList = NameSpace.AddressLists("All Contacts")
For Each Entry In AddressList.AddressEntries
I = I + 1
Cells(I, 1).Value = Entry.Name
Next
Finally:
Outlook.Quit
Set Outlook = Nothing
End Sub
specific Distribution List. Is there a way to break this down to that level?
Option Explicit
Public Sub DisplayOutlookContactNames()
Dim Outlook As Outlook.Application
Dim NameSpace As Outlook.NameSpace
Dim AddressList As AddressList
Dim Entry As AddressEntry
Dim I As Long
On Error GoTo Finally
Set Outlook = New Outlook.Application
Set NameSpace = Outlook.GetNamespace("MAPI")
Set AddressList = NameSpace.AddressLists("All Contacts")
For Each Entry In AddressList.AddressEntries
I = I + 1
Cells(I, 1).Value = Entry.Name
Next
Finally:
Outlook.Quit
Set Outlook = Nothing
End Sub