gpt4 book ai didi

vba - 如何共享 Outlook VBA

转载 作者:行者123 更新时间:2023-12-05 00:19:58 24 4
gpt4 key购买 nike

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com