This Microsoft Visual Basic example uses the Inspectors property and the Count property and Item method of the Inspectors object to display the captions of all inspector windows.
Dim myOlApp As New Outlook.Application
Private Sub Command1_Click()
If myOlApp.Inspectors.Count > 0 Then
For x = 0 To myOlApp.Inspectors.Count - 1
MsgBox Inspectors.Item(x).Caption
Next x
Else
MsgBox "There are no inspector windows open."
End If
End Sub
If you use VBScript, you do not declare an Application object variable. This example shows how to perform the same task using VBScript.
Sub Commandbutton1_Click()
If Application.Inspectors.Count > 0 Then
For x = 0 To Application.Inspectors.Count - 1
MsgBox Application.Inspectors.Item(x).Caption
Next
Else
MsgBox "There are no inspector windows open."
End If
End Sub