VBA/Excel/Access/Word/Application/ActiveInspector — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 16:33, 26 мая 2010

Check that the TypeName function does not return Nothing when run on the ActiveInspector method of the Application object:

 
Sub active()
    If TypeName(Application.ActiveInspector) = "Nothing" Then
        MsgBox "No item is open."
        End
    End If
End Sub



Using the Close Method

 
"Closes the active inspector and saves changes to its contents:
Sub saveMode()
    ActiveInspector.Close SaveMode:=olSave
End Sub



Using the SaveAs Method

 
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



Working with the Active Inspector

 
"Maximizes the window of the topmost inspector:
Sub window()
    Application.ActiveInspector.WindowState = olMaximized
End Sub