BeforeFolderSwitch Event 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