0
我有一些用戶希望在他們的Outlook中切換到日曆文件夾時選擇多個日曆。 所以我把一個示例代碼:Outlook 2010選擇日曆
http://www.slipstick.com/developer/code-samples/select-multiple-calendars-outlook/
修改了一些,給我的用戶。問題在於它不適用於其中一個Outlook,我無法找出原因。 下面是我的代碼,確切的問題是,這個宏不能「選擇/啓用」我想要的日曆 - 但如果我嘗試調試代碼並將MsgBox用於測試 - 看起來像代碼是在正確的位置。 Procmon沒有顯示任何「訪問被拒絕」或其他類型的錯誤。 你能幫我調查一下嗎?
Sub SelectCalendars()
Dim objPane As Outlook.NavigationPane
Dim objModule As Outlook.CalendarModule
Dim objGroupA, objGroupB As Outlook.NavigationGroup
Dim objNavFolder As Outlook.NavigationFolder
Dim objCalendar As Folder
Dim objFolder As Folder
Dim i As Integer
Dim test As Outlook.NavigationFolder
Set Application.ActiveExplorer.CurrentFolder = Session.GetDefaultFolder(olFolderCalendar)
DoEvents
Set objCalendar = Session.GetDefaultFolder(olFolderCalendar)
Set objPane = Application.ActiveExplorer.NavigationPane
Set objModule = objPane.Modules.GetNavigationModule(olModuleCalendar)
With objModule.NavigationGroups
Set objGroupA = .Item(1)
End With
' First calendar group
Set objNavFolder = objGroupA.NavigationFolders.Item(1)
MsgBox objNavFolder.DisplayName
MsgBox objNavFolder.IsSelected
objNavFolder.IsSelected = False
' Second calendar group
Set objNavFolder = objGroupA.NavigationFolders.Item(2)
MsgBox objNavFolder.DisplayName
MsgBox objNavFolder.IsSelected
objNavFolder.IsSelected = False
Set objPane = Nothing
Set objModule = Nothing
Set objGroup = Nothing
Set objNavFolder = Nothing
Set objCalendar = Nothing
Set objFolder = Nothing
End Sub