问题描述
我无法以编程方式在显示Outlook警报之前将其关闭.
I am having no luck dismissing an Outlook alert programmatically before it displays.
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
我想将此约会项目用作某些宏的触发器,而无需用户手动关闭提醒.
I want to use this appointment Item as a trigger to some macro without needing users to manually dismiss the reminder.
在我看来,触发此事件时,提醒项不可见,因此无法将其删除
Seems to me, when this event is triggered, the reminder item is NOT visible, thus cannot be dismissed
我试图将其从提醒集中删除,但这似乎从我的日历中删除了整个活动.另外,它仍会显示不是用ASCII表示的STRANGE TITLE提醒.
I tried to remove it from the reminders set but this seems to delete the whole event from my calendar. Also, it will still display a STRANGE TITLE reminder not in ASCII.
我试图将约会项的hinterSet属性设置为false,该提醒属性仍然弹出.
I tried to set the reminderSet property of the appointment item to false, the reminder property still pops up.
因此,我正在寻找一种方法,以a)在提醒自动弹出之前将其关闭/b).自动弹出提醒后将其关闭....或在Outlook中执行计划的MACRO的任何解决方法.(请注意,我无权在Windows或VBS中使用计划的作业.)
So I am looking for a way to a) dismiss the reminder before it pops automatically/ b). dismiss the reminder after it pops automatically....or any workaround to do a scheduled MACRO in Outlook.(Please note that I do not have permission to use scheduled job in Windows nor VBS.)
更新:
现在我有以下代码.提醒已被删除,但仍会弹出带有诸如没有约会/提醒"之类标题的提醒窗口.
Now I have the following code. The reminder is being removed, but it will still pop out a reminder window with a caption like "There is no appointment/reminder" something like this.
在提醒对象isVisible = true的意义上,beforeReminderShow事件很有用
The beforeReminderShow event is useful in the sense the Reminder Object isVisible = true
所以我可以解散..但即使有0个事件,提醒窗口也将继续弹出.
so I can dismiss out.. but the reminders windows will continue to pop up even if there's 0 event.
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"模块中).希望这对其他人有帮助.
[Solved] - final edit
The final solution workable (I placed in "ThisOutlookSession" Module).Hope this helps others.
' 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
推荐答案
我知道如何执行此操作的唯一方法如下.
The only way I know how to do this is as follows.
您需要在模块/类的顶部:
You need this at the top of your module/class:
Private WithEvents olRemind As Outlook.Reminders
然后,当您获取Outlook对象时,您需要执行以下操作:
Then when you get your Outlook object you need to do this:
Set olRemind = olApp.Reminders
olApp
是您的Outlook Application对象.
Where olApp
is your Outlook Application object.
现在,在您的代码中,您需要进行以下事件:
Now in your code you need to have this event:
Private Sub olRemind_BeforeReminderShow(Cancel As Boolean)
一旦将WithEvents
放在顶部,您将能够看到所有可以使用的事件.
Once you put the WithEvents
at the top then you will be able to see all the events you can use.
现在您可以取消此事件,因此看不到提醒窗口.
Now you can cancel this event and thus not see the reminder window.
这篇关于取消Outlook提醒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!