• Subject: Re: Make use of Events in Outlook
  • Author: Ken Slovak
  • Date: 06 Jul 2010
  • References: 1
The easiest way to handle events in Outlook VBA code is to use the
ThisOutlookSession class module, which is always in scope.

To get events on an appointment you need to handle first NewInspector() to
instantiate an event handling item and then handle events on the item.

In ThisOutlookSession, at the class level:

Dim WithEvents colInsp As Outlook.Inspectors
Dim WithEvents oAppt As Outlook.AppointmentItem

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

Private Sub colInspectors_NewInspector(Inspector As Inspector)
If Inspector.CurrentItem.Class = olAppointment Then
Set oAppt = Inspector.CurrentItem
End If
End Sub

That will instantiate the appointment object as an event handling object and
you then can handle the Close() and Write() events on the item.

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm

"Jan T." <noreply> wrote in message
news:OK2dnXJt0NUAd63RnZ2dnUVZ_uwAAAAA@posted.comnet...
> Hi. I want to run a procedure Sub MyProc() when I save or close an
> appointment
> that I just have created. I know there are some Events that are triggered,
> but how
> can I write code to make use of those Events?
>
> Class AppointmentItem
> Event Close(Cancel As Boolean)
> Event CustomAction(Action As Object, Response As Object, Cancel As
> Boolean)
>
> I appreciate very much any help, examples or suggestions. Thank's in
> advance!
>
> Regards
> Jan T.
>
>
04 Jul 2010Make use of Events in Outlook.Jan T.
06 Jul 2010\ Re: Make use of Events in Outlook.Ken Slovak
08 Jul 2010   \ Re: Make use of Events in Outlook.Jan T.
Contact Us
All times are in (US) Eastern Daylight Time (GMT -4:00)