Vba 取消Outlook提醒
我没有幸在Outlook警报显示之前以编程方式拒绝它Vba 取消Outlook提醒,vba,outlook,reminders,Vba,Outlook,Reminders,我没有幸在Outlook警报显示之前以编程方式拒绝它 Private Sub Application_Reminder(ByVal Item As Object) Dim objRem As Reminder Dim objRems As Reminders If Item.Subject = "TESTING" Then 'downloadAndSendSpreadReport Set objRems = Application.Remi
Private Sub Application_Reminder(ByVal Item As Object)
Dim objRem As Reminder
Dim objRems As Reminders
If Item.Subject = "TESTING" Then
'downloadAndSendSpreadReport
Set objRems = Application.Reminders
i = 0
For Each objRem In objRems
i = i + 1
If objRem.Caption = "TESTING" Then
objRems.Remove i
If objRem.IsVisible Then
objRem.Dismiss
End If
Exit For
End If
Next objRem
Item.ReminderSet = False
Item.Delete
'Item.Dismiss
End If
End Sub
我想将此约会项目用作某个宏的触发器,而不需要用户手动取消提醒
在我看来,当触发此事件时,提醒项不可见,因此无法取消
我试图将其从提醒集中删除,但这似乎将整个事件从我的日历中删除。此外,它仍然会显示一个奇怪的标题提醒,而不是ASCII格式
我试图将约会项目的提醒集属性设置为false,提醒属性仍然会弹出
因此,我正在寻找一种方法,a)在提醒自动弹出之前关闭提醒/b)。在提醒自动弹出后关闭提醒…或在Outlook中执行计划宏的任何解决方法。
(请注意,我无权在Windows或VBS中使用计划作业。)
更新:
现在我有了下面的代码。提醒正在被删除,但它仍会弹出一个提醒窗口,标题为“没有约会/提醒”,类似这样的内容
BeforeMemendorShow事件在提醒对象isVisible=true的意义上很有用
这样我就可以排除掉。。但即使有0个事件,提醒窗口仍将继续弹出
Private WithEvents olRemind As Outlook.Reminders
Private Sub olRemind_BeforeReminderShow(Cancel As Boolean)
Set objRems = Application.Reminders
For Each objRem In objRems
If objRem.Caption = "TESTING" Then
If objRem.IsVisible Then
objRem.Dismiss
End If
Exit For
End If
Next objRem
End Sub
[已解决]-最终编辑
最终的解决方案是可行的(我把它放在“ThisOutlookSession”模块中)。
希望这能帮助别人
' declare this object withEvents displaying all the events
Private WithEvents olRemind As Outlook.Reminders
Private Sub Application_Reminder(ByVal Item As Object)
Set olRemind = Outlook.Reminders
' RUN OTHER MACRO HERE
End Sub
Private Sub olRemind_BeforeReminderShow(Cancel As Boolean)
For Each objRem In olRemind
If objRem.Caption = "TESTING" Then
If objRem.IsVisible Then
objRem.Dismiss
Cancel = True
End If
Exit For
End If
Next objRem
End Sub
我知道如何做到这一点的唯一方法如下 您需要在模块/课程的顶部添加以下内容:
Private WithEvents olRemind As Outlook.Reminders
然后,当您获取Outlook对象时,需要执行以下操作:
Set olRemind = olApp.Reminders
其中,olApp
是Outlook应用程序对象
现在,在代码中,您需要有以下事件:
Private Sub olRemind_BeforeReminderShow(Cancel As Boolean)
将with events
置于顶部后,您将能够看到所有可使用的事件
现在,您可以取消此事件,从而看不到提醒窗口。如果要取消所有提醒,只需实现以下代码(用事件声明此对象
,显示所有事件):
我将在周一试一试,提前谢谢。我找不到这件事。谢谢在再次阅读你的问题后,我认为你必须将你已经拥有的和我的建议结合起来。我正在考虑这样一种情况:您希望删除提醒,但用户有其他提醒。在这种情况下,您删除您的,然后让提醒窗口显示。如果您的提醒是唯一的提醒,那么您将使用我建议的事件来停止窗口显示。在我看来,这样做没问题,还有问题吗?记住,如果你想停止窗口,你必须在某个地方取消=True。嗨,取消,谢谢你的帮助!你救了我一天谢谢@sparksustc,我已经在问题的末尾发布了我的最终可行版本。但是你的答案是上面darbid答案的实际实现。
Private WithEvents olRemind As Outlook.Reminders
Private Sub Application_Reminder(ByVal Item As Object)
Set olRemind = Outlook.Reminders
' RUN OTHER MACRO HERE
End Sub
Private Sub olRemind_BeforeReminderShow(Cancel As Boolean)
Cancel = True
End Sub