Compartir a través de


Explorer.BeforeFolderSwitch Event (Outlook)

Occurs before the explorer goes to a new folder, either as a result of user action or through program code.

Syntax

expression .BeforeFolderSwitch(NewFolder, Cancel)

expression A variable that represents an Explorer object.

Parameters

Name

Required/Optional

Data Type

Description

NewFolder

Required

Object

The Folder object the explorer is switching to.

Cancel

Required

Boolean

False when the event occurs. If the event procedure sets this argument to True, navigation is cancelled, and the current folder is not changed.

Remarks

This event is not available in Microsoft Visual Basic Scripting Edition (VBScript).

If the folder being switched to is in a namespace that doesn’t support automation (such as the file system), NewFolder is Nothing.

Example

This sample prevents a user from switching to a folder named "Off Limits". The sample code must be placed in a class module such as ThisOutlookSession, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook. To run this example without errors, make sure a folder by the name 'Off Limits' exists in the folder displayed in the active explorer.

Public WithEvents myOlExp As Outlook.Explorer 
 
 
 
Public Sub Initialize_handler() 
 
 Set myOlExp = Application.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

See Also

Concepts

Explorer Object Members

Explorer Object