Warning: Excel guy slowly learning Outlook Object.....
I've used the following code from Excel (with the CDO 1.21 Ref) to pull my companies GAL of approx 36,000 names to a spreadsheet.
Is there a better approach than below?
Thanks
Dave
[vba]
Sub Geta()
Dim NewMapi As MAPI.Session, MapiAdd As MAPI.AddressList, MapiAddEn As MAPI.AddressEntry
Dim OutputAR(), i As Long
Set NewMapi = New MAPI.Session
NewMapi.Logon 1, 1, False, False
Set MapiAdd = NewMapi.AddressLists("Global Address List")
ReDim OutputAR(1 To MapiAdd.AddressEntries.Count, 1 To 4)
On Error Resume Next
'ID may not exists
'Grab Name
'Grab Address
'Grab Logon
'Grab email
For Each MapiAddEn In MapiAdd.AddressEntries
i = i + 1
OutputAR(i, 1) = MapiAddEn.Name
OutputAR(i, 2) = MapiAddEn.Fields(975765534) & Chr(10) & MapiAddEn.Fields(975634462)
OutputAR(i, 3) = MapiAddEn.Fields(972947486)
OutputAR(i, 4) = MapiAddEn.Fields(973078558)
Next
Cells(1, 1) = "Name"
Cells(1, 2) = "Location"
Cells(1, 3) = "Email"
Cells(1, 4) = "Logon"
Cells(2, 1).Resize(i, UBound(OutputAR, 2)) = OutputAR()
Set MapiAdd = Nothing
Set NewMapi = Nothing
End Sub
[/vba]