Run-time error 287: Excel VBA Referencing Outlook Objects

dhancy

Board Regular
Joined
Jul 10, 2013
Messages
109
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

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,818
Messages
5,772,459
Members
425,760
Latest member
paphon

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
Top