VBA MS Outlook 2007 中用于创建自定义弹出警报的代码

VBA code in MS Outlook 2007 to create custom popup alert

我想在 MS Outlook 2007 中创建一个自定义弹出警报,它会在单击 "Send" 按钮时出现。它应该有 2 个选择:是和否。单击 "Yes" 时,我希望系统打开特定的 excel sheet。

是否可以通过向我的 Outlook 桌面客户端添加 VBA 代码片段来实现?我不知道如何着手实现这一目标。感谢任何潜在客户。

Application.ItemSend Event and simple MsgBox Function

合作

也看看这个回答

示例代码在 ThisOutlookSession

Public WithEvents olApp As Outlook.Application

Private Sub Application_Startup()
    Set olApp = Outlook.Application
End Sub

Private Sub olApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim xlApp As Excel.Application
    Dim xlBook As Workbook
    Dim Prompt As String

    Prompt = "Open Excel File?"

    If MsgBox(Prompt, vbYesNo + vbQuestion, _
                            "Sample") = vbNo Then
        Cancel = True
    Else
        Set xlApp = New Excel.Application
        Set xlBook = xlApp.Workbooks.Open( _
                               "C:\Temp\Temp.xlsm")
        xlApp.Visible = True

    End If

    Set xlApp = Nothing
    Set Book = Nothing
End Sub