다음을 통해 공유


ViewSwitch Event

Occurs when the view in the explorer changes, either as a result of user action or through program code. This event is not available in Microsoft Visual Basic Scripting Edition (VBScript).

Subobject**_ViewSwitch()**

*object   * An expression that evaluates to an Explorer object.

Example

This Visual Basic for Applications (VBA) example hides the preview pane if it is visible when the user switches to Messages with AutoPreview view. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myolapp As New Outlook.Application
Dim WithEvents myOlExpl As Outlook.Explorer

Sub Initialize_handler()
    Set myOlExpl = myolapp.ActiveExplorer
End Sub

Private Sub myOlExpl_ViewSwitch()
    If myOlExpl.CurrentView = "Messages with AutoPreview" And myOlExpl.IsPaneVisible(olPreview) = True Then
        myOlExpl.ShowPane olPreview, False
    End If
End Sub

Applies to | Explorer Object

See Also | BeforeFolderSwitch Event | BeforeViewSwitch Event | FolderSwitch Event | SelectionChange Event | Using events with Automation