Outlook VBA code debugging

Joined
Jun 10, 2011
Messages
1
Reaction score
0
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:

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
Thanks in advance! Any help is really appreicated!

Nolan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top