ActiveInspector Method
Returns the topmost Inspector object on the desktop. If no inspector is active, returns Nothing. Use this method to access the Inspector object that the user is most likely to be viewing.
expression.ActiveInspector
expression Required. An expression that returns an Application object
Remarks
If the user’s default e-mail editor is Microsoft Word, and if the message format of the item being edited is plain text or HTML, the ActiveInspector method produces an error and returns Nothing.
Example
This Visual Basic for Applications example uses the ActiveInspector method to demonstrate how to obtain the currently active Inspector object and display the name of the item that the inspector is displaying.
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
If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using 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