返回桌面上顶层的 Inspector 对象。如果没有活动的检查器,则返回 Nothing。使用此方法访问用户最可能查看的 Inspector 对象。
expression.ActiveInspector
expression 必选。该表达式返回 Application 对象。
如果用户的默认电子邮件编辑器为 Microsoft Word,并且如果编辑的项目的邮件格式为纯文本或 HTML,则 ActiveInspector 方法产生错误并返回 Nothing。
本 Visual Basic for Applications 示例使用 ActiveInspector 方法演示如何获得当前活动的 Inspector 对象,并显示检查器正在显示的项目的名称。
Sub GetInspector()
'Displays the subject of the active Inspector
Dim myolapp As Outlook.Application
Dim myinspector As Inspector
Set myolapp = CreateObject("Outlook.Application")
Set myinspector = myolapp.ActiveInspector
'Test if an inspector is active
If Not TypeName(myinspector) = "Nothing" Then
'Display subject of active inspector
MsgBox "The active item is " & myinspector.CurrentItem.Subject
End If
End Sub
如果使用 VBScript,则不创建 Application 对象,而且也不能使用命名常量。本示例说明如何使用 VBScript 执行相同任务。
Sub ActiveInspector()
'Displays the name of the active Inspector
Set myinspector = Application.ActiveInspector
'Test if an Inspector is active
If Not TypeName(myinspector) = "Nothing" Then
'Display subject of active inspector
MsgBox "The active item is " & myinspector.CurrentItem.Subject
End If
End Sub