在功能窗格中顯示特定模組

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物件的參考。

下列範例會在功能窗格中,將 [郵件] 巡覽模組設定為目前選定的巡覽模組 (如已透過程式設計方式,或是透過使用者動作選取了任何巡覽模組)。 The sample performs the following actions:

  1. 此範例會在引發 Application 物件的Startup事件並將它 objPane 指派給 時,先取得使用中 Explorer 之NavigationPane物件的參考,以便偵測到NavigationPane物件的ModuleSwitch事件。

  2. NavigationPaneModuleSwitch事件發生時,範例會在ModuleSwitch事件的 CurrentModule 參數中檢查NavigationModule 物件參照的 NavigationModuleType屬性。

  3. 如果目前所選 NavigationModule 物件的 NavigationModuleType 屬性設定為 olModuleMail ,範例便會使用 NavigationPane 物件之 NavigationModules 集合的 GetNavigationModule 方法,嘗試擷取 MailModule 物件。 如果成功,範例最終會將 NavigationPane 物件的 CurrentModule 屬性設定為所擷取的 MailModule 物件參照。

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

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應