我在VBA for Outlook中创建了一个宏 . 我希望在Outlook打开时始终启用此宏 .
-
如何才能使Outlook不必让我允许这个宏运行?如何使其成为“可信”的宏 .
-
与同事分享此宏的最佳方式是什么?
这是宏脚本,代码工作正常,我正在寻求与我办公室其他人分享这个的帮助:
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 回答
您可以在Outlook中调整信任中心设置,或者只使用数字签名对宏进行签名 . 有关更多信息,请参见Troubleshooting Outlook VBA和Signing your own macros with SelfCert.exe .
VBA宏不是为分发而设计的 . 所有可能的方法都在To distribute Microsoft Outlook VBA code to other users页面上描述 .
相反,我建议改为开发加载项 . 有关更多信息,请参见Walkthrough: Creating Your First Application-Level Add-in for Outlook .