共用方式為


在功能窗格中將模組設定為目前選取的模組

在 Microsoft Outlook 中使用NavigationPane物件的CurrentModule屬性,將NavigationModule物件設定為Explorer物件之功能窗格中目前選取的流覽模組。

下列範例會在以程式或透過使用者動作選取 [日誌] 巡覽模組時,將 [行事曆] 巡覽模組設定為功能窗格中目前選取的巡覽模組。 The sample performs the following actions:

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

  2. NavigationPaneModuleSwitch事件發生時,範例會比較ModuleSwitch事件的CurrentModule參數內容與NavigationPane物件的CurrentModule屬性,以檢查目前的流覽模組是否已變更。

  3. 如果這些物件參考不同,則範例會檢查ModuleSwitch事件之CurrentModule 參數中 NavigationModule 物件參考的 NavigationModuleType屬性。

  4. If the NavigationModuleType property of the currently selected Module object is set to olModuleJournal, the sample then displays a dialog box to indicate to the user that the currently selected Journal navigation module is temporarily unavailable, and that instead the Calendar navigation module will be selected.

  5. 最後,此範例會使用NavigationPane物件之Modules集合的GetNavigationModule方法,嘗試擷取CalendarModule物件。 如果成功,NavigationPane 物件的 CurrentModule 屬性就會設定成所擷取的 CalendarModule 物件參照。

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 CalendarModule 
 
 ' Check if the currently selected navigation module 
 ' has changed. 
 If Not (CurrentModule Is objPane.CurrentModule) Then 
 ' If the Journal module was selected, forcibly change 
 ' it to the Calendar module by setting the 
 ' CurrentModule property of the NavigationPane object. 
 If CurrentModule.NavigationModuleType = olModuleJournal Then 
 
 ' Let the user know what's happening. 
 MsgBox "The Journal module is temporarily unavailable. " & _ 
 " Outlook is switching to the Calendar module, if available." 
 
 ' Retrieve the Calendar module, if one exists, for the 
 ' current Navigation Pane. 
 Set objModule = objPane.Modules.GetNavigationModule(olModuleCalendar) 
 
 ' If we have one, set the CurrentModule property of the 
 ' NavigationPane object to the Calendar module. 
 If Not (objModule Is Nothing) Then 
 Set objPane.CurrentModule = objModule 
 End If 
 End If 
 End If 
 
End Sub

支援和意見反應

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