Run-time error 287: Excel VBA Referencing Outlook Objects

dhancy

Board Regular
Joined
Jul 10, 2013
Messages
123
Office Version
  1. 365
Platform
  1. Windows
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
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top