【问题标题】:VBA code in Outlook 2016 and 2019 works differentOutlook 2016 和 2019 中的 VBA 代码工作方式不同
【发布时间】:2020-12-06 06:46:27
【问题描述】:

我有两个电脑设置:

  1. Win10 Pro Build 1909 和 Outlook 2019 for Business
  2. Win10 Pro Build 2004 和 Outlook 2016 for Business

(一切原创)

我的问题是,为什么相同的 VBA 代码在 2019 年有效,而在 Outlook 2016 中无效。问题出在 Outlook 或不同版本的构建 MS Win10 上?

这部分代码不起作用:

ThisOutlookSession

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

     Dim objMailPuvodni As Outlook.MailItem
     Dim CurrentItem As Object
     Dim lngOdpoved As Long


     Select Case TypeName(Application.ActiveWindow)
     Case "Inspector"
        
        Set objMailPuvodni = Application.ActiveInspector.CurrentItem
    Case "Explorer"
        
        If Application.ActiveExplorer.Selection.Item(1).Class = _
           OlObjectClass.olMail Then
            
            Set objMailPuvodni = _
            Application.ActiveExplorer.Selection.Item(1)
        End If
    End Select


    lngOdpoved = MsgBox("text", _
                    vbQuestion + vbYesNoCancel + vbDefaultButton2, _
                    "Send")

    Select Case lngOdpoved
        Case vbCancel
            Cancel = True
        Case vbNo
        
        Cancel = False
            Case vbYes
        
        Call SifrovatZip(objMailPuvodni)
        
        Cancel = True
    End Select


    Set objMailPuvodni = Nothing

End Sub

更新 @nilton 回答有效

【问题讨论】:

  • 那么究竟是什么不起作用?是否返回了特定错误?
  • @Dmitry Streblechenko 没有错误,VBA 脚本在 Outlook 2016 中什么都不做,没有 msgbox 显示等等。
  • 这通常是因为升级时忘记允许宏Enable or disable macros in Office files
  • @nilton 谢谢,工作。重新启用宏,关闭 Outlook 并保存 VBA 宏,然后工作。

标签: vba outlook windows-10 windows-update


【解决方案1】:

@nilton's answer in the comments 工作:

这通常是由于在升级时忘记允许宏 Enable or disable macros in Office files

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-22
    • 1970-01-01
    • 1970-01-01
    • 2023-01-31
    • 1970-01-01
    相关资源
    最近更新 更多