【发布时间】:2015-03-23 01:44:16
【问题描述】:
这个在 Excel VBA 应用程序中运行良好多年的子程序,在显示电子邮件供我发送 (.Display) 之前将 Outlook 签名插入到电子邮件中。这在 Windows XP 中的 Excel 2007 和 Windows 7 中的 2013 中有效。
现在我有 Windows 8.1 和 Office 2013,在我的错误例程中出现错误 91。参考文献之一可能有问题吗? - 还是需要对代码进行一些更改?
Sub InsertSig2007(strSigName As String)
Dim objItem As Object
Dim objInsp As Outlook.Inspector
' requires a project reference to the
' Microsoft Office library
Dim objCBP As Office.CommandBarPopup
Dim objCBP2 As Office.CommandBarPopup
Dim objCBB As Office.CommandBarButton
Dim colCBControls As Office.CommandBarControls
Set objInsp = ActiveInspector
If Not objInsp Is Nothing Then
Set objItem = objInsp.CurrentItem
If objItem.Class = olMail Then
' get Insert menu
Set objCBP = objInsp.CommandBars.ActiveMenuBar.FindControl(, 30005)
' get Signature submenu
Set objCBP2 = objCBP.CommandBar.FindControl(, 5608)
If Not objCBP2 Is Nothing Then
Set colCBControls = objCBP2.Controls
For Each objCBB In colCBControls
Debug.Print objCBB.Caption
If objCBB.Caption = strSigName Then
objCBB.Execute ' **** see remarks
Exit For
End If
Next
End If
End If
End If
Set objInsp = Nothing
Set objItem = Nothing
Set colCBControls = Nothing
Set objCBB = Nothing
Set objCBP = Nothing
Set objCBP2 = Nothing
End Sub
【问题讨论】:
-
看起来很脆。它在哪条线上失败了?