当用户在 Outlook 面板的快捷方式上单击以导航到不同文件夹时发生。该事件在 VBScript 中不可用。
Sub object_BeforeNavigate(ByVal Shortcut As OutlookBarShortcut, Cancel As Boolean)
object 该表达式的值为 OutlookBarPane 对象。
Shortcut 必选。用户单击的快捷方式。
Cancel 可选。当事件发生时为 False。如果事件过程将该参数设置为 True,将不更改当前的文件夹。
本示例防止用户使用“Outlook 面板”打开“便笺”文件夹。示例代码必须放在类模块中,并且在 Microsoft Outlook 调用该事件过程前必须调用 Initialize_handler
例程。
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