如何使application.reminder事件起作用? [英] How do I make the application.reminder event work?

查看:71
本文介绍了如何使application.reminder事件起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在类模块中有此代码-如 msdn 此stackoverflow线程

I have this code in a class module - as stated to on msdn and on this stackoverflow thread

Public WithEvents objReminders As Outlook.Reminders

Private Sub Application_Startup()
    Set objReminders = Application.Reminders
End Sub

Private Sub Application_Reminder(ByVal Item As Object)
    Call Send_Email_Using_VBA
    MsgBox ("Litigate!") 
End Sub

我尝试使用此线程并且也不会启动.

I have tried using the code at the bottom of this thread and that won't launch either.

我所能获得的就是Outlook的提醒弹出窗口.即使没有删除函数调用,也不会显示任何断点,Msgbox也不会显示.我已经重启了好几次,但没有结果.

All I can get is outlook's reminders popup. No breakpoints are ever hit, the Msgbox never shows - even if I remove the function call. I have restarted it several times and I have no result.

我想念一些重要的东西吗?

Am I missing something important?

推荐答案

您正在使用WithEvents处理objReminders对象上的Reminder事件,但并未声明要匹配的子项.在下面的代码中,请注意objReminders_...与您的Application_...子代码.

You are using WithEvents to handle your Reminder events on the objReminders object, but you are not declaring the subs to match. In my code below, please note the objReminders_... vs. your Application_... subs.

我在Outlook 2003中使用了您的代码(我没有Office 2007,因此无法在那里进行测试),并提出了以下建议:

I played with your code in Outlook 2003 (I do not have Office 2007, so I cannot test there), and came up with the following:

Public WithEvents objReminders As Outlook.Reminders

Private Sub objReminders_Snooze(ByVal ReminderObject As Reminder)
    Call Send_Email_Using_VBA
    MsgBox ("Litigate!")
End Sub

Private Sub Class_Initialize()
    Set objReminders = Outlook.Reminders
End Sub

在常规代码模块中对此进行了实现:

Implemented with this in a normal code module:

Sub test()

Dim rmd As New ReminderClass

rmd.objReminders.Item(1).Snooze 1 'Triggers objReminders_Snooze in class module
rmd.objReminders.Item(2).Snooze 1

End Sub

现在,这是在我显式调用的Snooze事件上触发的.但是,这也应该使您在事件首次出现时触发(据我所知,这不会在提醒从Snooze唤醒时触发).我没有设置任何提醒来进行测试-如果您还有其他困难,我将为此设置一些我自己的测试.

Now, this is triggering on the Snooze event, which I explicitly call. However, this should also work for you to trigger when the event first comes up (this does not, as far as I can tell, trigger when a reminder wakes from a Snooze). I did not have any reminders set up to test - if you have difficulties beyond this, I will set up a few of my own tests with regard to that.

Private Sub objReminders_ReminderFire(ByVal ReminderObject As Reminder)
    Call Send_Email_Using_VBA
    MsgBox ("Litigate!")
End Sub


更新:

在2010年尝试此方法后,我发现以下方法可以工作(至少起火,但它似乎经常起火):

After playing around with this in 2010, I found the following to work (at least fire, but it seemed to constantly fire):

Private Sub Application_Reminder(ByVal Item As Object)
    Call Send_Email_Using_VBA
    MsgBox ("Litigate!")
End Sub

这是在ThisOutlookSession对象模块中设置的.添加这个对您有什么作用吗?

This was set up in the ThisOutlookSession object module. Does adding this do anything for you?

这篇关于如何使application.reminder事件起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆