在导航窗格中显示特定模块Display Specific Modules in the Navigation Pane

在 Microsoft Outlook 中, NavigationPane 对象的**CurrentModule** 属性确定当前显示在导航窗格中的导航模块。The CurrentModule property of the NavigationPane object, in Microsoft Outlook, determines which navigation module is currently displayed in the Navigation Pane. 您可以通过枚举**NavigationModules** 集合或使用NavigationModules集合的**GetNavigationModule** 方法,从NavigationPane对象中检索对给定**NavigationModule** 对象的引用。You can retrieve a reference to a given NavigationModule object from a NavigationPane object by either enumerating the NavigationModules collection or by using the GetNavigationModule method of the NavigationModules collection.

如果通过编程方式或通过用户操作在导航窗格中选定了任何导航模块,下面的示例会将 “邮件” 导航模块设置为当前选定的导航模块。The following sample sets the Mail navigation module as the currently selected navigation module if any navigation module is selected, either programmatically or by user action, in the Navigation Pane. 本示例执行下列操作:The sample performs the following actions:

  1. 在引发**Application** 对象的objPane启动 事件并将其分配给时,示例将首先获取对活动浏览器的NavigationPane对象的引用,以便可以检测到NavigationPane对象的**ModuleSwitch** 事件。The sample first obtains a reference to the NavigationPane object for the active explorer when the Startup event of the Application object is raised and assigns it to objPane, so the ModuleSwitch event of the NavigationPane object can be detected.

  2. NavigationPaneModuleSwitch事件发生时,示例将在CurrentModule事件的_ModuleSwitch_参数中检查NavigationModule对象引用的**NavigationModuleType** 属性。When the ModuleSwitch event of the NavigationPane occurs, the sample then checks the NavigationModuleType property of the NavigationModule object reference in the CurrentModule parameter of the ModuleSwitch event.

  3. 如果当前选定的 NavigationModule 对象的 NavigationModuleType 属性设置为 olModuleMail ,示例将使用 NavigationPane 对象的 NavigationModules 集合的 GetNavigationModule 方法尝试检索 MailModule 对象。If the NavigationModuleType property of the currently selected NavigationModule object is set to olModuleMail, the sample uses the GetNavigationModule method of the NavigationModules collection for the NavigationPane object to attempt to retrieve a MailModule object. 如果成功,示例最终会将 NavigationPane 对象的 CurrentModule 属性设置为检索到的 MailModule 对象引用。If successful, the sample finally sets the CurrentModule property of the NavigationPane object to the retrieved MailModule object reference.

Dim WithEvents objPane As NavigationPane 
 
Private Sub Application_Startup() 
 ' Get the NavigationPane object for the 
 ' currently displayed Explorer object. 
 Set objPane = Application.ActiveExplorer.NavigationPane 
End Sub 
 
Private Sub objPane_ModuleSwitch(ByVal CurrentModule As NavigationModule) 
 Dim objModule As MailModule 
 
 If CurrentModule.NavigationModuleType <> olModuleMail Then 
 ' Use the GetModule method to obtain a MailModule from 
 ' the current NavigationPane object. 
 Set objModule = objPane.Modules.GetNavigationModule(olModuleMail) 
 
 ' Set the CurrentModule property to the MailModule. 
 Set objPane.CurrentModule = objModule 
 End If 
End Sub

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.