VBA/Excel/Access/Word/Application/ActiveInspector

Материал из VB Эксперт
Версия от 12:46, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

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