共用方式為


列舉行事曆檢視中的使用中資料夾

In Microsoft Outlook, you can traverse the group and folder hierarchy of a module in the Navigation Pane by using the NavigationGroups and NavigationFolders collections. NavigationModule物件的NavigationGroups集合包含流覽模組中顯示的每個流覽群組,而NavigationGroup物件的NavigationFolders集合則包含流覽群組中顯示的每個流覽資料夾。

藉由搭配使用這些集合,您便可針對顯示於功能窗格中的巡覽模組,列舉其各個巡覽資料夾。

The following sample counts the number of navigation folders selected for display in the Calendar navigation module of the Navigation Pane. The sample performs the following actions:

  1. 本範例會先取得使用中瀏覽器之 NavigationPane 物件的參照。

  2. 然後,它會使用NavigationModules集合的GetNavigationModule方法,從NavigationPane物件取得CalendarModule物件的參考。

  3. 此範例接著會列舉CalendarModule物件的NavigationGroups集合。 針對集合中的每個 NavigationGroup ,此範例接著會列舉 NavigationFolders 集合。

  4. 如果NavigationFolders集合中所包含之NavigationFolder物件的IsSelected屬性設定為True,則變數 intCounter 會遞增。

  5. 最後,此範例會顯示包含 值的 intCounter 對話方塊。

Dim WithEvents objPane As NavigationPane 
 
Private Sub EnumerateActiveCalendarFolders() 
 Dim objModule As CalendarModule 
 Dim objGroup As NavigationGroup 
 Dim objFolder As NavigationFolder 
 Dim intCounter As Integer 
 
 On Error GoTo ErrRoutine 
 
 ' Get the NavigationPane object for the 
 ' currently displayed Explorer object. 
 Set objPane = Application.ActiveExplorer.NavigationPane 
 
 ' Get the CalendarModule object, if one exists, 
 ' for the current Navigation Pane. 
 Set objModule = objPane.Modules.GetNavigationModule(olModuleCalendar) 
 
 ' Iterate through each NavigationGroup contained 
 ' by the CalendarModule. 
 For Each objGroup In objModule.NavigationGroups 
 ' Iterate through each NavigationFolder contained 
 ' by the NavigationGroup. 
 For Each objFolder In objGroup.NavigationFolders 
 ' Check if the folder is selected. 
 If objFolder.IsSelected Then 
 intCounter = intCounter + 1 
 End If 
 Next 
 Next 
 
 ' Display the results. 
 MsgBox "There are " & intCounter & " selected calendars in the Calendar module." 
 
EndRoutine: 
 On Error GoTo 0 
 Set objFolder = Nothing 
 Set objGroup = Nothing 
 Set objModule = Nothing 
 Set objPane = Nothing 
 intCounter = 0 
 Exit Sub 
 
ErrRoutine: 
 MsgBox Err.Number & " - " & Err.Description, _ 
 vbOKOnly Or vbCritical, _ 
 "EnumerateActiveCalendarFolders" 
End Sub

支援和意見反應

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