VBA宏-自定义回复按钮



我写了一个宏来在回复窗口上添加密件地址。但我想做同样的点击"回复"按钮。我不能添加宏到这个按钮,因为它不是自定义按钮。我该怎么做呢?

您可以重新使用内置控件。但是在这种情况下,您需要开发一个外接程序,而不是一个VBA宏。有关详细信息,请参阅Office Fluent功能区中的临时重新使用命令。

还可以尝试处理Application类的ItemSend事件,该事件在发送Microsoft Outlook项目时触发,无论是由用户通过检查器发送(在检查器关闭之前,但在用户单击Send按钮之后)还是当Outlook项目的Send方法(例如MailItem)在程序中使用时。在事件处理程序中,您可以尝试将'Type'属性设置为olBcc的新条目添加到收件人集合(参见相应的属性)。

来自超级用户。

https://superuser.com/questions/327614/outlook-macro-to-interrupt-a-reply-all

"你可以通过VBA添加一个事件处理程序来拾取ReplyAll事件。像这样:"

Dim WithEvents insp As Outlook.Inspectors
Dim WithEvents mailItem As Outlook.MailItem
' This is called on Outlook startup
Private Sub Application_Startup()
    Set insp = Application.Inspectors
End Sub
' This is called when a new Inspector is created.
' You use it to pick up on a new mail item event
Private Sub insp_NewInspector(ByVal Inspector As Inspector)
    ' Edit:  The size test appears to be incorrect
    'If Inspector.CurrentItem.Size = 0 And Inspector.CurrentItem.Class = olMail Then
    If Inspector.CurrentItem.Class = olMail Then
       Set mailItem = Inspector.CurrentItem
    End If
End Sub
' Called when you press ReplyAll
Private Sub mailItem_ReplyAll(ByVal Response As Object, Cancel As Boolean)
    Dim msg As String
    Dim result As Integer
    msg = "Do you really want to reply to all?"
    result = MsgBox(msg, vbYesNo, "Reply All Check")
    If result = vbNo Then
        Cancel = True
    End If
End Sub

将代码放入ThisOutlookSession模块中,然后重新启动。

最新更新