VBA Outlook 2016 和 2019 中的代码工作方式不同

VBA code in Outlook 2016 and 2019 works different

我有两个 PC 设置:

  1. 带有 Outlook 2019 for Business 的 Win10 Pro Build 1909
  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 回答有效

@nilton's answer in the comments 作品:

Typically this is due to forgetting to allow macros Enable or disable macros in Office files when upgrading.