Explorer onOpen event

  • Thread starter Thread starter BartH_NL
  • Start date Start date
B

BartH_NL

Hello,

Who could inform me on how I can run code at the open event of a (new
e-mail) explorer? I need to check the value of a saved variable as soon
as the user wants to compose a new e-mail message.

The code I have, sits in the Outlook VBAProject.OTM. Code I have found
in the newsgoups and kbs is mainly used for add-ins and I can't (as a
simple test) get a messagebox set off at opening of a new e-mail
message. If someone could help me get that - I'll be on my way.

Thanks,
Bart
 
Explorer is a folder view. You want NewInspector, that's for open items
(Inspector).

In the ThisOutlookSession class module in Outlook VBA:

Dim WithEvents colInsp As Outlook.Inspectors

'in Application_Startup:
Private Sub Application_Startup()
Set colInsp = Application.Inspectors
End Sub

Private Sub NewInspector(Inspector As Inspector)
'whatever you want to do
End Sub
 
Hi Ken,

Good to get you guidance again. Sorry, I indeed ment to address the
Inspector

I'm half way now. I used your code an built a little test:

Dim WithEvents colInsp As Outlook.Inspectors

'in Application_Startup:
Private Sub Application_Startup()
Set colInsp = Application.Inspectors
MsgBox "App is running"
End Sub

Private Sub NewInspector(Inspector As Inspector)
'whatever you want to do
MsgBox "Insp is running 2"
End Sub

I do get "App is running" when I start Outlook, but when I then fire a
new e-mail message (or any other inspector), I don't get "Insp is
running 2".

I cleaned out all code of ThisOutlookSession so there can be nothing to
interfere.

What's missing?

Regards,
Bart
 
I got sloppy writing that off the top of my head :(

It should be:

Private Sub colInsp_NewInspector(ByVal Inspector As Inspector)

You can always pull down the Object drop-down and select your event enabled
objects and in the right-hand drop-down select from the available events to
insert a template of the event handler.
 
Thanks, that's the one!

Grtz,
Bart
I got sloppy writing that off the top of my head :(

It should be:

Private Sub colInsp_NewInspector(ByVal Inspector As Inspector)

You can always pull down the Object drop-down and select your event enabled
objects and in the right-hand drop-down select from the available events to
insert a template of the event handler.
 
Back
Top