vba 关闭 Outlook 提醒
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13283989/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Dismiss Outlook reminder
提问by Larry
I am having no luck dismissing an Outlook alert programmatically before it displays.
我没有运气在它显示之前以编程方式关闭 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.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
在我看来,当触发此事件时,提醒项不可见,因此无法解除
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.
我试图从提醒集中删除它,但这似乎从我的日历中删除了整个事件。此外,它仍然会显示一个非 ASCII 的奇怪标题提醒。
I tried to set the reminderSet property of the appointment item to false, the reminder property still pops up.
我尝试将约会项的remoteSet属性设置为false,仍然弹出提醒属性。
So I am looking fora 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.)
所以我正在寻找一种方法来 a) 在它自动弹出之前关闭提醒/ b)。在它自动弹出后关闭提醒......或任何在 Outlook 中执行预定宏的解决方法。(请注意,我无权在 Windows 或 VBS 中使用计划作业。)
Updates:
更新:
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.
现在我有以下代码。提醒正在被删除,但它仍然会弹出一个提醒窗口,标题为“没有约会/提醒”之类的。
The beforeReminderShow event is useful in the sense the Reminder Object isVisible = true
beforeReminderShow 事件在提醒对象 isVisible = true 的意义上很有用
so I can dismiss out.. but the reminders windows will continue to pop up even if there's 0 event.
所以我可以解雇..但即使有 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
[Solved] - final edit
The final solution workable (I placed in "ThisOutlookSession" Module).
Hope this helps others.
[已解决] - 最终编辑
最终解决方案可行(我放置在“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
采纳答案by darbid
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
Then when you get your Outlook object you need to do this:
然后,当您获得 Outlook 对象时,您需要执行以下操作:
Set olRemind = olApp.Reminders
Where olApp
is your Outlook Application object.
olApp
您的 Outlook 应用程序对象在哪里。
Now in your code you need to have this event:
现在在你的代码中你需要有这个事件:
Private Sub olRemind_BeforeReminderShow(Cancel As Boolean)
Once you put the WithEvents
at the top then you will be able to see all the events you can use.
将 放在WithEvents
顶部后,您将能够看到所有可以使用的事件。
Now you can cancel this event and thus not see the reminder window.
现在您可以取消此事件,从而看不到提醒窗口。
回答by sparksustc
If you want to dismiss all the reminders, you can simply implement the following code (declare this object WithEvents
displaying all the events):
如果要关闭所有提醒,只需实现以下代码(声明此对象WithEvents
显示所有事件):
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