BeforeFolderSwitch Event
Occurs before 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.
Note If the folder being switched to is in a name space that doesn’t support Automation (such as the file system), NewFolder is Nothing.
Sub object_BeforeFolderSwitch(ByVal NewFolder As Object, Cancel As Boolean)
object An expression that evaluates to an Explorer object.
NewFolder Required. The MAPIFolder object the explorer is switching to.
Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, navigation is cancelled and the current folder is not changed.
Example
This sample prevents a user from switching to a folder named Off Limits. 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_BeforeFolderSwitch(ByVal NewFolder As Object, Cancel As Boolean)
If NewFolder.Name = "Off Limits" Then
MsgBox "You do not have permission to access this folder."
Cancel = True
End If
End Sub