如何使用 VBA 添加 MS Outlook 提醒事件处理程序
我想扩展 MS Outlook,以便当弹出日历提醒时,我可以运行一个可以运行外部程序(如批处理脚本)的 VBA 挂钩。就我而言,我想将提醒“转发”到 Linux 桌面,因为我在这两种环境中工作,并且 Windows 桌面并不总是可见。
我在 http://office.microsoft.com/en- 看到一个示例us/outlook-help/HV080803406.aspx 并在 MS Outlook 2010 中打开 VBA 开发人员视图并插入一个类模块并添加该 VBA 代码,但我不知道如何激活此代码 - 当弹出提醒时,此代码未被激活。
更新
这是我最终添加到 Outlook 的 ThisOutlookSession 中的内容,以便在弹出提醒时运行外部批处理脚本。
Public WithEvents objReminders As Outlook.Reminders
Private Sub Application_Startup()
Set objReminders = Application.Reminders
End Sub
Private Sub objReminders_ReminderFire(ByVal ReminderObject As Reminder)
Cmd = "C:\path\to\my\reminder-hook.cmd" & " " & ReminderObject.Caption
Call Shell(Cmd, vbHide)
End Sub
I want to extend MS Outlook so that when a calendar reminder pops up, I can run a VBA hook that can run an external program (like a batch script). In my case, I want to "forward" the reminder to a Linux desktop since I work in both environments and I don't always have the Windows desktop visible.
I see an example at http://office.microsoft.com/en-us/outlook-help/HV080803406.aspx and have opened VBA Developer view in MS outlook 2010 and inserted a class module and added that VBA code, but I do not see how to activate this code - when a reminder pops up, this code is not activated.
Update
Here is what I ended up adding to Outlook's ThisOutlookSession to run an external batch script when a reminder pops up.
Public WithEvents objReminders As Outlook.Reminders
Private Sub Application_Startup()
Set objReminders = Application.Reminders
End Sub
Private Sub objReminders_ReminderFire(ByVal ReminderObject As Reminder)
Cmd = "C:\path\to\my\reminder-hook.cmd" & " " & ReminderObject.Caption
Call Shell(Cmd, vbHide)
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将其放入“ThisOutlookSession”模块中并重新启动 Outlook。
另外,请确保在 Outlook 设置中启用宏。
Put it in the "ThisOutlookSession" module and restart Outlook.
Also, ensure that macros are enabled in Outlook settings.