Error 287 on Inspector.Close()

S

Synced

Hey gang.

Fairly new to automating office/outlook. I am working on a COM add-in
written in VB6.

I am getting an error 287 when trying to do a Close() call on an Inspector
or MailItem.

I did a bunch of read up and this seems to be related to the security
features in office however my Application object does say it is trusted so
why am I hitting this issue?

So how do I work around this? Am I doing something wrong?

Any help would be greatly appreciated.

Thanks!
 
D

Dmitry Streblechenko

What is teh relevant snippet off your code?
When exactly is your code executed (a particular event handler etc)?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
S

Synced

It's coming from the Click event from the following:
Private WithEvents m_btnClose As CommandBarButton

The weird thing is I thought when security comes into play the prompts are
supposed to appear? I don't get any prompts just error 287.

Any help would be greatly appreciated and thanks for the help!
 
S

Synced

I can't even do the following for example:

Dim olInspector as Inspector
Set olInspector = Application.Inspectors(1)
olInspector.Close(olDiscard)

I get the 287 error. I also get the 287 error if I try to close a MailItem
in the CommandBarButton Click event.

Any ideas what I am doing wrong? Is error 287 always related to security?
Like I said in the other post. I thought code security was supposed to prompt
when security is becoming an issue.

I'm not getting any prompts, just error 287 exceptions.

Thanks again in advance for all the help.
 
D

Dmitry Streblechenko

olInspector is one of the OlObjectClass enums, you cannot have a varable
with that name.
Secondly, change the code to the following (notice Inspectors.Item)

Set Inspector = Application.Inspectors.Item(1)
Inspector.Close(olDiscard)

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 

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