I have code in ThisOutlookSession module from run a macro when creating new appointment in outlook:
Private WithEvents appt As AppointmentItem
Private WithEvents objinspectors As Outlook.Inspectors
Private Sub Application_Startup()
Set objinspectors = Application.Inspectors
End Sub
Private Sub objinspectors_NewInspector(ByVal Inspector As Inspector)
If TypeName(Inspector.CurrentItem) = "AppointmentItem" Then
Set appt = Inspector.CurrentItem
End If
End Sub
Private Sub appt_Write(ByVal Item As Object, Cancel As Boolean)
'---- ect
end sub
appt_Write works for the first appointment I create or modify. If I create a second appointment nothing happens.
I found the sub objinspectors_NewInspector does not start anymore.
I have no END
command in my code. To run the code again I have to launch Application_Startup.
What should I do to make the macro work all time?