Run-time error 287: Excel VBA Referencing Outlook Objects

dhancy

Board Regular
Joined
Jul 10, 2013
Messages
100
Hello,

As I continue my studies into how to navigate the Outlook hierarchy using Excel VBA, I find that I often run into Run-time error '287':

Please forgive me for asking another question on this subject.

First, my understanding of the Outlook hierarchy is this:

Outlook Application
- Namespace
--- Address Lists
----- Address List
------- Address Entries
--------- Address Entry

If this is not correct, let me know as this might be the source of all my 287 errors.

Here is a snippet of my code:

VBA Code:
Dim olApp As Outlook.Application
Dim olNS As Outlook.Namespace
Dim olAddLists As Outlook.AddressLists
Dim olGAL As Outlook.AddressList
Dim olEntries As Outlook.AddressEntries
Dim olEntry As Outlook.AddressEntry

Set olApp = Outlook.Application
Set olNS = olApp.GetNamespace("MAPI")
Set olAddLists = olNS.AddressLists

For Each olGAL In olAddLists
   Set olEntries = olGAL.AddressEntries
   For Each olEntry In olEntries
      …
   Next
Next

The 287 error comes on the "Set olEntries" line.

I have Windows 10 and Office 2016.

Tools/References include:
- Visual Basic for Applications
- Microsoft Excel 16.0 Object Library
- OLE Automation
- Microsoft Office 16.0 Office Library
- Microsoft Outlook 16.0 Object Library


Any idea of what I am doing wrong here?


Thanks again.


Dennis
 

Some videos you may like

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Watch MrExcel Video

Forum statistics

Threads
1,114,513
Messages
5,548,496
Members
410,840
Latest member
Kar3ousse
Top