View Single Post
  #3  
Old December 4th 08, 08:06 PM posted to microsoft.public.outlook.program_vba
Patrik
external usenet poster
 
Posts: 3
Default code for event: everytime i save an item ...


thanks a lot!
it's very simple if you know the code ... ;-)


"Ken Slovak - [MVP - Outlook]" wrote:

It's possible. You need to get a reference to the item that's opened and
then handle its Write() event. You get a NewInspector() event when an item
is opened, that would let you get a handle to the item being opened. You get
NewInspector() when you handle events for the Inspectors collection. So for
VBA this would work:

1. Select the ThisOutlookSession class module. Add your code there.

2. Add this code:

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

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

Private Sub colInsp_NewInspector(ByVal Inspector As Inspector)
If Inspector.CurrentItem.Class = olAppointment Then
boolStartup = True
Set oAppt = Inspector.CurrentItem
End If
End Sub

Private Sub oAppt_Write(Cancel As Boolean)
' whatever
End Sub

That will initialize things when Outlook starts up and whenever you open an
appointment item you can then handle its Write() event.

--
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


"Patrik" wrote in message
...
outlook 2007:
i would like to start a VBA code everytime i click to save (new or changed
appointment? - so do ...)
is this possible with vBA?



Ads