【发布时间】:2014-12-23 21:03:51
【问题描述】:
我在通过 Outlook 2007 发送的每条消息上都放置了一个新的 VBA 脚本,以便我自己自动密件抄送。该代码似乎运行良好。我遇到的问题是,每次我重新启动计算机并加载 Outlook 2007 时,代码才会在我打开 VBA 编辑器之后才使用。即使我关闭编辑器,它也会继续以这种方式正常运行。每次打开 Outlook 2007 时是否必须打开然后关闭 VBA 编辑器?有没有办法在打开和加载 Outlook 2007 时强制 VBA 脚本参与?
这是我正在使用的脚本:
Private Sub Application_ItemSend(ByVal Item As Object, _
Cancel As Boolean)
Dim objRecip As Recipient
Dim strMsg As String
Dim res As Integer
Dim strBcc As String
On Error Resume Next
' #### USER OPTIONS ####
' address for Bcc -- must be SMTP address
' or resolvable to a name in the address book
strBcc = "email@domain.com"
Set objRecip = Item.Recipients.Add(strBcc)
objRecip.Type = olBCC
If Not objRecip.Resolve Then
strMsg = "Could not resolve the Bcc recipient. " & _
"Do you want to send the message?"
res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
"Could Not Resolve Bcc")
If res = vbNo Then
Cancel = True
End If
End If
Set objRecip = Nothing
End Sub
【问题讨论】:
-
看来问题来自您的信任中心设置。您需要在 Outlook 中调整宏安全设置。尝试将其设置为最低级别。
标签: vba loading outlook-2007