【问题标题】:How to share Outlook VBA如何共享 Outlook VBA
【发布时间】:2015-09-25 01:00:21
【问题描述】:

我在 VBA 中为 Outlook 创建了一个宏。我希望在 Outlook 打开时始终启用此宏。

  1. 如何才能使 Outlook 不必要求我允许此宏运行?如何使其成为“受信任”宏。

  2. 与同事共享此宏的最佳方式是什么?

这是宏脚本,代码运行良好,我正在寻求与我办公室的其他人共享此代码的帮助:

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

  Dim Recipients As Outlook.Recipients
  Dim recip As Outlook.Recipient
  Dim i
  Dim prompt As String
  Dim checklist As String
  Dim lbadFound  As Boolean
  Dim badAddresses As String
  lbadFound = False

On Error Resume Next
 ' use lower case for the address
 ' LCase converts all addresses in the To field to lower case

 ' checklist contains the names and email addresses of people involved in the Build Option

  checklist = "test@gmail.com" 

 Set Recipients = Item.Recipients
    For i = Recipients.Count To 1 Step -1
      Set recip = Recipients.Item(i)

      If InStr(1, LCase(checklist), LCase(recip)) >= 1 Then
          lbadFound = True
          badAddresses = badAddresses & recip & vbCrLf
      End If

    Next i

    If lbadFound Then
       prompt$ = "You are sending this email to one or more people on the Build Team: " & vbCrLf & vbCrLf & badAddresses & vbCrLf & " Are you sure you want to send it?"
       If MsgBox(prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check Address") = vbNo Then
         Cancel = True
       End If
    End If

End Sub

【问题讨论】:

    标签: vba outlook


    【解决方案1】:

    1) 我怎样才能使 Outlook 不必要求我允许此宏运行?如何使其成为“受信任的”宏。

    您可以调整 Outlook 中的信任中心设置,或者仅使用数字签名对宏进行签名。有关详细信息,请参阅 Troubleshooting Outlook VBASigning your own macros with SelfCert.exe

    2) 与同事分享此宏的最佳方式是什么?

    VBA 宏不是为分发而设计的。 To distribute Microsoft Outlook VBA code to other users 页面上描述了所有可能的方法。

    相反,我建议开发一个加载项。请参阅Walkthrough: Creating Your First Application-Level Add-in for Outlook 了解更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-20
      • 1970-01-01
      • 1970-01-01
      • 2022-12-13
      • 2019-03-24
      相关资源
      最近更新 更多