如何使用VBA添加MS Outlook提醒事件处理程序 [英] How to add MS outlook reminders event handlers with VBA
问题描述
我想扩展MS Outlook,以便在弹出日历提醒时可以运行一个VBA挂钩,该挂钩可以运行一个外部程序(例如批处理脚本).就我而言,我想将提醒转发"到Linux桌面,因为我在两种环境中都可以工作,而且我并不总是能看到Windows桌面.
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.
我在 http://office.microsoft.com上看到了一个示例/en-us/outlook-help/HV080803406.aspx ,并已在MS Outlook 2010中打开了VBA开发人员视图,并插入了一个类模块并添加了该VBA代码,但我看不到如何激活此代码-弹出提醒,此代码未激活.
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.
这是我最终添加到Outlook的ThisOutlookSession中以在弹出提醒时运行外部批处理脚本的内容.
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
推荐答案
将其放在"ThisOutlookSession"模块中,然后重新启动Outlook.
Put it in the "ThisOutlookSession" module and restart Outlook.
此外,请确保在Outlook设置中启用了宏.
Also, ensure that macros are enabled in Outlook settings.
这篇关于如何使用VBA添加MS Outlook提醒事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!