FolderSwitch Event

Microsoft Outlook Visual Basic

FolderSwitch Event

       

Occurs when the explorer navigates to a new folder, either as a result of user action or through program code. This event is not available in VBScript.

Sub object_FolderSwitch()

object   An expression that evaluates to an Explorer object.

Example

This example shows or hides a menu bar, depending on the folder that is visible. 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 Outlook.Application
Public WithEvents myOlExp As Outlook.Explorer

Public Sub Initialize_handler()
    Set myOlExp = myOlApp.ActiveExplorer
End Sub

Private Sub myOlExp_FolderSwitch()
    Select Case MyOlExp.CurrentFolder.Name
        Case "Sales Contacts"
            MyToolsMenu.Visible = True
        Case Else
            MyToolsMenu.Visible = False
    End Select
End Sub