Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to add an event handler to double click on a mail

47 views
Skip to first unread message

Lars Hauschultz

unread,
May 9, 2001, 6:46:50 AM5/9/01
to
Hi all,
how do I respond to a user's double click on a mail in an Outlook window? I
want to have Outlook execute a vba macro instead of opening the mail. My
macros are stored in an Outlook project (OTM-file).

TIA Lars


Sue Mosher

unread,
May 9, 2001, 8:12:06 AM5/9/01
to
You could run your macro from the Inspectors.NewInspector event. Add this
code to the ThisOutlookSession module:

Public WithEvents colInsp As Inspectors

Private Sub Application_Startup()
Set colInsp = Inspectors
End Sub

Private Sub colInsp_NewInspector(ByVal Inspector As Inspector)
' call your macro here
End Sub

--

Sue Mosher, Outlook MVP
Author of
Teach Yourself Microsoft Outlook 2000 Programming in 24 Hours
Microsoft Outlook 2000 E-mail and Fax Guide
Outlook and Exchange solutions at http://www.slipstick.com

"Lars Hauschultz" <l...@infocom.dk> wrote in message
news:OvPn9VH2AHA.1480@tkmsftngp03...

Lars Hauschultz

unread,
May 9, 2001, 10:42:26 AM5/9/01
to
Hi Sue,
thanks for your answer.
The event handler responds all right to the double click, but the inspector
opens afterwards anyway. Do you know how I may prevent it from being opened?

Lars

Sue Mosher <sue...@slipstick.com> wrote in message
news:u1vmHMI2AHA.1736@tkmsftngp02...

Lars Hauschultz

unread,
May 9, 2001, 10:50:03 AM5/9/01
to
I found the answer myself and added:

Public WithEvents anInsp As Inspector

Private Sub colInsp_NewInspector(ByVal Inspector As Inspector)

....
Set anInsp = Inspectors.Item(Inspectors.Count)
End Sub

Private Sub anInsp_Activate()
anInsp.Close (olDiscard)
Set anInsp = Nothing
End Sub


Lars Hauschultz <l...@infocom.dk> wrote in message

news:uiU9jZJ2AHA.1956@tkmsftngp03...

Sue Mosher

unread,
May 9, 2001, 10:52:28 AM5/9/01
to
Add code to close it:

Inspector.Close olDiscard

"Lars Hauschultz" <l...@infocom.dk> wrote in message

news:uiU9jZJ2AHA.1956@tkmsftngp03...

Sue Mosher

unread,
May 9, 2001, 12:14:27 PM5/9/01
to
I like your version better than mine <g>, but why are you setting anInsp to
the Count rather than using the Inspector object that the NewInspector event
passes you?

"Lars Hauschultz" <l...@infocom.dk> wrote in message

news:#KVxMeJ2AHA.632@tkmsftngp03...

Lars Hauschultz

unread,
Jun 1, 2001, 2:34:49 AM6/1/01
to
I might have misunderstood something when I originally assumed that "ByVal"
meant that I do not get the actual address of the Inspector. From your
question I must assume that I get the pointer to the Inspector ByVal and
thus have the address.

Thanks,
Lars


Sue Mosher <sue...@slipstick.com> wrote in message

news:u$SujPK2AHA.1956@tkmsftngp03...

Sue Mosher

unread,
Jun 1, 2001, 7:53:59 AM6/1/01
to
The Inspector object that the NewInspector event handler passes as an
argument is all you need.

"Lars Hauschultz" <l...@infocom.dk> wrote in message

news:e5gm1Tm6AHA.1984@tkmsftngp05...

0 new messages