vba - 如何共享 Outlook VBA

标签 vba outlook

我已经在 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

最佳答案

1) How can I make it so Outlook does not have to ask me to allow this macro to run? How do I make it a 'trusted' macro.

您可以在 Outlook 中调整信任中心设置,或者只使用数字签名对宏进行签名。参见 Troubleshooting Outlook VBASigning your own macros with SelfCert.exe想要查询更多的信息。

2) What is the best way to share this macro with colleagues?

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

相反,我建议开发一个插件。参见 Walkthrough: Creating Your First Application-Level Add-in for Outlook想要查询更多的信息。

关于vba - 如何共享 Outlook VBA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31270277/

相关文章:

excel - Microsoft Excel 2010 复制/粘贴编辑想法和小细节帮助请求

c# - C#/.NET (VS 2008) 到 Outlook (2007) 的问题

c++ - FindwindowEx for Outlook 2010

vbscript - 使用多个签名由 GPO 自动生成 Outlook 签名

html - 展望负表 margin

Excel - 禁用 F11 按键

excel - "if and"具有两列条件的语句

excel - VBA .Attachments.Add 方法抛出错误

excel - VBA InStr 与 Excel 工作表中的标准

html - 在图像右侧居中放置两行文本