Hi again and thank you for your answer. However I am having some problems to
put in
what ever is missing. I tried to implement the code as below but not very
successfully:
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
MsgBox "New Inspector.."
End If
End Sub
Private Sub oAppt_Open(Cancel As Boolean)
MsgBox "New appointment item.."
End Sub
All code above, I put into ThisOutlookSession.
What am I missing here?
"Ken Slovak" <kenslovak@mvps.org> skrev i melding
news:i0vck9$fbu$3@news.eternal-september.org...
> 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.
>>
>>
>