![Outlook 2013 VBA:在阅读窗格中引用编辑器](https://linux22.com/image/1418999/Outlook%202013%20VBA%EF%BC%9A%E5%9C%A8%E9%98%85%E8%AF%BB%E7%AA%97%E6%A0%BC%E4%B8%AD%E5%BC%95%E7%94%A8%E7%BC%96%E8%BE%91%E5%99%A8.png)
我尝试在发送消息时为其分配一个类别(“立即发送”类别以覆盖发送延迟)。在单独的窗口中编辑消息时,下面的宏工作正常,但当我尝试在阅读窗格编辑器中编辑消息时运行宏,它会挂在“Set msg = insp.CurrentItem”行,并显示错误消息“未设置对象变量或 With 块变量”。
当编辑器停靠时,如何正确引用它?是否有条件测试可用于测试正在使用的编辑器类型?
谢谢!
Public Sub SendNow()
Dim msg As Outlook.MailItem
Dim insp As Outlook.Inspector
Set insp = Application.ActiveInspector
Set msg = insp.CurrentItem
If insp.EditorType = olEditorWord Then ' outlook 2013
msg.Categories = "Send Now"
End If
msg.Save
msg.Send
Set insp = Nothing
Set msg = Nothing
End Sub
答案1
看一看:
Set exp = Application.ActiveExplorer
Set msg = exp.ActiveInlineResponse
If Not msg Is Nothing Then
...