Explorer.FolderSwitch event (Outlook)
Occurs when the explorer goes to a new folder, either as a result of user action or through program code.
expression A variable that represents an Explorer object.
This event is not available in Microsoft Visual Basic Scripting Edition (VBScript).
The following Microsoft 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.
Public WithEvents myOlExp As Outlook.Explorer
Public Sub Initialize_handler()
Set myOlExp = Application.ActiveExplorer
Private Sub myOlExp_FolderSwitch()
Select Case myOlExp.CurrentFolder.Name
myOlExp.CurrentView = "Messages"
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.