I have some users who would like to have multiple calendars selected when they switch to calendar folder in theirs Outlook. So I took a sample code from:
http://www.slipstick.com/developer/code-samples/select-multiple-calendars-outlook/
Modified it a little and gave to my users. Problem is that it is not working on one of these Outlooks and I cannot find out why. Below is my code and the exact problem is that this macro cannot "select/enable" the calendar I want - but if I try to debug the code and put MsgBox for testing - looks like the code is in right place. Procmon is not showing any "access denied" or other kind of errors. Could You help me to investigate this ?
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