首页 文章

如何共享Outlook VBA

提问于
浏览
1

我在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 回答

相关问题