笔记:
必须用`Set olApp = CreateObject("Outlook.Application")`。
选择组:
```
With objModule.NavigationGroups
' Set objGroup = .GetDefaultNavigationGroup(olMyFoldersGroup)
' To use a different group
Set objGroup = .Item("仪器相关")
End With
```
选择组下的一个日历:
```
for i = 1 To objGroup.NavigationFolders.Count
Set objNavFolder = objGroup.NavigationFolders.Item(i)
if objNavFolder.DisplayName = "" then
objNavFolder.IsSelected = True
exit for
end if
next
```
---------------------------------------------
# coding
Sub SelectCalendars()
Dim objPane As Outlook.NavigationPane
Dim objModule As Outlook.CalendarModule
Dim objGroup As Outlook.NavigationGroup
Dim objNavFolder As Outlook.NavigationFolder
Dim objCalendar As Folder
Dim objFolder As Folder
Set olApp = CreateObject("Outlook.Application")
Dim i As Integer
'Set olApp.ActiveExplorer.CurrentFolder = Session.GetDefaultFolder(olFolderCalendar)
DoEvents
'Set objCalendar = Session.GetDefaultFolder(olFolderCalendar)
Set objPane = olApp.ActiveExplorer.NavigationPane
Set objModule = objPane.Modules.GetNavigationModule(olModuleCalendar)
With objModule.NavigationGroups
' Set objGroup = .GetDefaultNavigationGroup(olMyFoldersGroup)
' To use a different group
Set objGroup = .Item("仪器相关")
End With
For i = 1 To objGroup.NavigationFolders.Count
Set objNavFolder = objGroup.NavigationFolders.Item(i)
MsgBox objNavFolder.DisplayName
Select Case i
' Enter the calendar index numbers you want to open
Case 1, 3, 4
objNavFolder.IsSelected = True
' Set to True to open side by side
objNavFolder.IsSideBySide = False
Case Else
objNavFolder.IsSelected = False
End Select
Next
' set the view here
Set objPane = Nothing
Set objModule = Nothing
Set objGroup = Nothing
Set objNavFolder = Nothing
Set objCalendar = Nothing
Set objFolder = Nothing
End Sub