Hi All,
I am getting the 'Object Vairable or With Block Variable not set' error when I try to execute the following code and I'm not sure why. I'm new to Outlook VBA, so it's probably something obvious that I'm missing:
Thanks in advance! Any help is really appreicated!
Nolan
I am getting the 'Object Vairable or With Block Variable not set' error when I try to execute the following code and I'm not sure why. I'm new to Outlook VBA, so it's probably something obvious that I'm missing:
Code:
Sub GetGALContacts()
Dim outApp As Object, outNS As Outlook.NameSpace
Dim mtxAddressList As Outlook.AddressList
Dim mtxGALEntries As AddressEntries
Dim mtxGALEntry As AddressEntry
Dim thisContact As ContactItem
Set outApp = CreateObject("Outlook.Application")
Set outNS = outApp.GetNamespace("MAPI")
Set mtxAddressList = outNS.session.AddressLists("Global Address List")
Set mtxGALEntries = mtxAddressList.AddressEntries
For Each mtxGALEntry In mtxGALEntries
'Test if this record is from sync
Set thisContact = mtxGALEntry.GetContact
MsgBox thisContact.FirstName <--Error occurs here
Next mtxGALEntry
Set outApp = Nothing
End Sub
Nolan