关闭Outlook提醒

问题描述 投票:8回答:2

我没有运气在显示之前以编程方式解除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

我想使用此约会项作为某些宏的触发器,而无需用户手动关闭提醒。

在我看来,当触发此事件时,提醒项目不可见,因此无法解除

我试图从提醒集中删除它,但这似乎从我的日历中删除了整个事件。此外,它仍将显示不是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

[解决] - 最终编辑 最终解决方案可行(我放在“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
vba outlook outlook-vba reminders
2个回答
4
投票

我知道如何做到这一点的唯一方法如下。

您需要在模块/类的顶部:

Private WithEvents olRemind As Outlook.Reminders

然后,当您获得Outlook对象时,您需要这样做:

Set olRemind = olApp.Reminders

其中olApp是您的Outlook应用程序对象。

现在在你的代码中你需要有这个事件:

Private Sub olRemind_BeforeReminderShow(Cancel As Boolean)

一旦你将WithEvents放在顶部,你就可以看到你可以使用的所有事件。

现在您可以取消此活动,从而看不到提醒窗口。


3
投票

如果要关闭所有提醒,可以简单地实现以下代码(声明此对象显示所有事件的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
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.