FolderSwitch Event
Occurs when the explorer goes to a new folder, either as a result of user action or through program code. This event is not available in Microsoft Visual Basic Scripting Edition (VBScript).
Subobject**_FolderSwitch()**
*object * An expression that evaluates to an Explorer object.
Example
The following Microsoft Visual Basic/Visual Basic for Applications (VBA) example displays the Inbox folder in "Messages" view whenever the user switches to the Inbox folder. 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
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 "Inbox"
myOlExp.CurrentView = "Messages"
Case Else
End Select
End Sub
Applies to | Explorer Object
See Also | BeforeFolderSwitch Event | BeforeViewSwitch Event | SelectionChange Event | Using events with Automation | ViewSwitch Event