Lar*_*rry 8 outlook vba reminders outlook-vba
我没有运气在显示之前以编程方式解除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
Run Code Online (Sandbox Code Playgroud)
我想使用此约会项作为某些宏的触发器,而无需用户手动关闭提醒.
在我看来,当触发此事件时,提醒项目不可见,因此无法解除
我试图从提醒集中删除它,但这似乎从我的日历中删除了整个事件.此外,它仍将显示不是ASCII格式的STRANGE TITLE提醒.
我试图将约会项目的reminderSet属性设置为false,仍会弹出提醒属性.
所以我正在寻找一种方法来a)在它自动弹出/ b)之前解除提醒.在自动弹出后解除提醒....或者在Outlook中执行预定MACRO的任何解决方法.(请注意,我无权在Windows和VBS中使用预定作业.)
更新:
现在我有以下代码.提醒正在删除,但它仍会弹出一个提醒窗口,其标题为"没有预约/提醒"这样的内容.
在Reminder Object isVisible = true的意义上,beforeReminderShow事件很有用
所以我可以解雇..但即使有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
Run Code Online (Sandbox Code Playgroud)
[已解决] - 最终编辑
最终解决方案可行(我置于"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
Run Code Online (Sandbox Code Playgroud)
我知道如何做到这一点的唯一方法如下。
您需要在模块/类的顶部使用它:
Private WithEvents olRemind As Outlook.Reminders
Run Code Online (Sandbox Code Playgroud)
然后,当您获得 Outlook 对象时,您需要执行以下操作:
Set olRemind = olApp.Reminders
Run Code Online (Sandbox Code Playgroud)
olApp您的 Outlook 应用程序对象在哪里。
现在在你的代码中你需要有这个事件:
Private Sub olRemind_BeforeReminderShow(Cancel As Boolean)
Run Code Online (Sandbox Code Playgroud)
将 放在WithEvents顶部后,您将能够看到所有可以使用的事件。
现在您可以取消此事件,从而看不到提醒窗口。
小智 5
如果要关闭所有提醒,只需实现以下代码(声明此对象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
Run Code Online (Sandbox Code Playgroud)