VBA/Excel/Access/Word/Application/ActiveInspector
Содержание
Check that the TypeName function does not return Nothing when run on the ActiveInspector method of the Application object:
<source lang="vb">
Sub active()
If TypeName(Application.ActiveInspector) = "Nothing" Then MsgBox "No item is open." End End If
End Sub
</source>
Using the Close Method
<source lang="vb">
"Closes the active inspector and saves changes to its contents: Sub saveMode()
ActiveInspector.Close SaveMode:=olSave
End Sub
</source>
Using the SaveAs Method
<source lang="vb">
Sub saveAs()
If TypeName(ActiveInspector) = "Nothing" Then MsgBox "This macro cannot run because " & _ "there is no active window.", vbOKOnly, "Macro Cannot Run" End Else If ActiveInspector.IsWordMail Then ActiveInspector.CurrentItem.SaveAs "c:\message.doc" Else ActiveInspector.CurrentItem.SaveAs "c:\message.rtf" End If End If
End Sub
</source>
Working with the Active Inspector
<source lang="vb">
"Maximizes the window of the topmost inspector: Sub window()
Application.ActiveInspector.WindowState = olMaximized
End Sub
</source>