我在run a macro when creating new appointment in outlook:
的ThisOutlookSession模块中有代码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适用于我创建或修改的第一个约会。如果我创建第二个约会没有任何反应。
我发现sub objinspectors_NewInspector不再启动了。
我的代码中没有END
命令。要再次运行代码,我必须启动Application_Startup。
我应该怎么做才能让宏一直工作?
答案 0 :(得分:0)
Private Sub appt_Write(ByVal Item As Object, Cancel As Boolean)
'---- etc
Set objinspectors = Application.Inspectors 'add this line ... see what happens
End Sub