BeforeNavigate Event

Microsoft Outlook Visual Basic

Show All

BeforeNavigate Event

       

Occurs when the user clicks on an Outlook Bar shortcut to navigate to a different folder. This event is not available in VBScript.

Sub object_BeforeNavigate(ByVal Shortcut As OutlookBarShortcut, Cancel As Boolean)

object   An expression that evaluates to an OutlookBarPane object.

Shortcut   Required. The shortcut that the user clicked.

Cancel   Optional. False when the event occurs. If the event procedure sets this argument to True, the current folder is not changed.

Example

This example prevents the user from using the Outlook Bar to open the Notes 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 myOlPane As Outlook.OutlookBarPane

Public Sub Initialize_handler()
    Set myOlPane = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
End Sub
Private Sub myOlPane_BeforeNavigate(ByVal Shortcut As Outlook.OutlookBarShortcut, Cancel As Boolean)
    If Shortcut.Name = "Notes" Then
        MsgBox "You cannot view the Notes folder."
        Cancel = True
    End If
End Sub