Outlook事件未触发

用户名

我正在尝试根据日历提醒发送一封电子邮件。

我无法让VBA宏识别发生Outlook事件。

我把这段代码放在一个类模块中:

Public WithEvents myOlApp As Outlook.Application

Sub Initialize_handler()
    Set myOlApp = Outlook.Application 'also tried with double quotes around "Outlook.Application"
End Sub

Private Sub myOlApp_Reminder(ByVal Item As Object)
    MsgBox ("test")
End Sub

Private Sub myOlApp_NewMail()
    MsgBox ("test")
End Sub

当我收到新的电子邮件或提醒消失时,什么都没有发生。

我已经在正常模块中对此宏进行了测试,并且可以正常工作:

Sub MsgBoxTest()
    MsgBox ("test")
End Sub

我在信任中心的“启用所有宏”上有宏设置。

我已经搜索了google,stackoverflow,许多其他网站,并阅读了Microsoft.com上的文档。

我在运行Windows 10企业版的PC上使用Outlook 2016。

尼通

对于此方法(通常在文档中使用),可以Initialize_handler手动运行,也可以在启动时在特殊类模块中运行ThisOutlookSession

Private Sub Application_Startup()
    Initialize_handler
End Sub

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章