Use this macro to select multiple calendars and open them in overlay mode. If you are using iCloud and don't want the iCloud calendars selected by default, you can use this method to deselect the iCloud calendars. See Deselect iCloud Calendars for more information and the necessary code.
This code sample assumes that the calendars are all in the My Calendars group.

If the calendars are all in another group, you can use this line to identify the group and select the calendars in it:
Set objGroup = .Item("group name")
In this code sample, I'm opening calendars #1, 3, and 4 in the My Calendars group. To open 2 and 5 (New Stuff and a mailbox Calendar in the screenshot), I'd use Case 2, 5
When you use Outlook 2013 and all of the calendars are in one group, you can select the group to show all.
To use, set macro security to low, open the VBA editor by pressing Alt+F11 then paste this into a new module. Assign it to a ribbon or toolbar button and run. More complete instructions are at How to use the VBA Editor.
To use a specific view, see set a view at the end of this article.
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
Dim i As Integer
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 objGroup = .GetDefaultNavigationGroup(olMyFoldersGroup)
' To use a different group
' Set objGroup = .Item("group name")
End With
For i = 1 To objGroup.NavigationFolders.Count
Set objNavFolder = objGroup.NavigationFolders.Item(i)
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 SubAutomatically select specific calendars when switching to the calendar module
If you want to always have certain calendars selected when you switch to the calendar module, you can add an Application_Startup macro to the code. Every time you select the calendar module, the calendars listed in the Case statement will be selected.
To use this macro, add it to ThisOutlookSession. Click in the Application_Startup macro and press Run to enable it without restarting Outlook.
Dim WithEvents objPane As NavigationPane
Private Sub Application_Startup()
Set objPane = Application.ActiveExplorer.NavigationPane
End Sub
Private Sub objPane_ModuleSwitch(ByVal CurrentModule As NavigationModule)
Dim objPane As NavigationPane
Dim objModule As CalendarModule
Dim objGroup As NavigationGroup
Dim objNavFolder As NavigationFolder
Dim objCalendar As Folder
Dim objFolder As Folder
Dim i As Integer
If CurrentModule.NavigationModuleType = olModuleCalendar Then
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 objGroup = .GetDefaultNavigationGroup(olMyFoldersGroup)
' To use a different group
' Set objGroup = .Item("group name")
End With
For i = 1 To objGroup.NavigationFolders.Count
Set objNavFolder = objGroup.NavigationFolders.Item(i)
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
End If
Set objPane = Nothing
Set objModule = Nothing
Set objGroup = Nothing
Set objNavFolder = Nothing
Set objCalendar = Nothing
Set objFolder = Nothing
End Sub
Select Specific Calendar When Outlook Starts
Outlook is starting with the user's Calendar and not the one we want selected.
If the calendar is in an account in your profile, you can select the calendar in File, Options, Advanced and select it as the startup folder. If it's not available to select, you might be able to use a command line switch to choose the correct calendar. See "Choose the Folder Outlook Starts Up In" for details.
This code selects a specific calendar when Outlook starts up. You need to set Outlook to start in the Calendar folder for it to work.
Private Sub Application_Startup()
Dim objPane As NavigationPane
Dim objModule As CalendarModule
Dim objGroup As NavigationGroup
Dim objNavFolder As NavigationFolder
Set objPane = Application.ActiveExplorer.NavigationPane
Set objModule = objPane.Modules.GetNavigationModule(olModuleCalendar)
With objModule.NavigationGroups
Set objGroup = .GetDefaultNavigationGroup(olMyFoldersGroup)
End With
On Error Resume Next
Set objNavFolder = objGroup.NavigationFolders.Item(2)
DoEvents
objNavFolder.IsSelected = True
objNavFolder.IsSideBySide = False
DoEvents
Set objNavFolder = objGroup.NavigationFolders.Item(1)
objNavFolder.IsSelected = False
'set the view here
End Sub
Deselect iCloud Calendars
Many iCloud users don't appreciate that Apple has all iCloud calendars selected by default when you open Outlook. If you are one of these users, you can use the following code sample to deselect the iCloud calendars. Replace the block of code between With objModule.NavigationGroups and the last End If in the automatic macro above with the code below.
With objModule.NavigationGroups
Set objGroup = .Item("iCloud")
End With
For i = 1 To objGroup.NavigationFolders.Count
Set objNavFolder = objGroup.NavigationFolders.Item(i)
Select Case i
' Enter the calendar index numbers you want to close
Case 1, 2
If objNavFolder.IsSelected = True Then
objNavFolder.IsSelected = False
Else
End If
' we'll deselect any we missed
Case Else
objNavFolder.IsSelected = False
End Select
Next
End If
Set a specific view on the Calendar
Outlook will generally use the last view you used on the calendar. If you want to use a specific view with the macros above, you can set the view in the code.
Add this code before the end of the macros above to set the calendar to the day view. If the macro has an End if at the end, add it before the End If.
Dim objViews As Views
Dim objView As View
Set objViews = Application.ActiveExplorer.CurrentFolder.Views
Set objView = objViews.Item("Calendar")
With objView
' Set the calendar view to show a
' single day.
.CalendarViewMode = olCalendarViewDay
End With
objView.Apply
| Name | Description |
|---|---|
| olCalendarView5DayWeek | Displays a 5-day week. |
| olCalendarViewDay | Displays a single day. |
| olCalendarViewMonth | Displays a month. |
| olCalendarViewMultiDay | Displays a number of days equal to the DaysInMultiDayMode property value of the CalendarView object. |
| olCalendarViewWeek | Displays a 7-day week. |
More Information
How to: Add a Custom Folder to a Group and Display it in Overlay Mode by Default (MSDN)
Macro code that displays several shared calendars (Outlookcode.com)
Ty S says
I am selecting 15 calendars under a "shared calendars" group and that is working. But by default it is selecting them all under both my default calendar and schedule view. I then have to toggle day view and Schedule View to get the stacked one to go away. Screenshot here.
Is there a way that I can choose Schedule View by default?
Keith Collyer says
I've successfully used this code to open all my calendars in one overlaid weekly view. What I haven't managed to do is to get Outlook to set the specific calendar to use for New Appointment or New Meeting. Which calendar gets chosen seems almost random, though it seems to be consistent after an application of the macro it may change on the next application.
Ideally, I want the New ... functions to default to my personal calendar.
Walt Bilofsky says
Diane,
Thanks so much for "Automatically select specific calendars when switching to the calendar module." It does a great job of displaying my three calendars (two shared) in one.
I have two questions:
1) With Outlook set to start in Calendar, it only displays Calendar on startup. My workaround is to start in Contacts and switch to Calendar. But is there a way to force objPane_ModuleSwitch to run on startup?
2) The first time the calendars are displayed, the third one is selected. Every time after that it's the first one. How can the first one be selected all the time?
I tried
For i = objGroup.NavigationFolders.Count To 1 Step -1
but then the second folder was selected the first time; still the first one after that.
Best,
Walt
Keith Collyer says
Just realised my question is essentially the same as the second question here.
247it says
Hi,
what code can I use after the calendar selection to just go (back) to the default inbox email folder? I'm now in the calendar view.
BR
Diane Poremsky says
You'll add a line to change the module to olModuleMail - add it at the end and it should move you back to the mail module. (I'll test it to verify)
Diane Poremsky says
First bug: you need to either use a new object name or change the DIM:
Dim objModule 'As CalendarModule
Beyond that, I'm still getting errors if I try to set a calendar format then switch back using code.
Jerry says
I need some help if possible. I use Outlook 2016 running on an Intel compute stick hooked up to a 65" TV. I want Outlook to open and display 3 Internet calendars (Google Calendars ics) in column view. I used the code above such that when I select the calendar icon in Outlook all 3 calendars open perfectly. However, the last part I'm stuck on is how to I get Outlook to open in that view by default, that is, startup and automatically display the 3 calendars. I can select one Internet calendar to open in the advanced options but not all 3 at once. Can this be achieved by coding?
Thanks,
Jerry
Diane Poremsky says
I have never tried it, but it should work. (It actually should remember the last selected calendars (assuming outlook closes correctly and doesn't crash), if you started in email or outlook today and switched to the calendar manually.)
From https://www.slipstick.com/developer/code-samples/select-multiple-calendars-outlook/#start
This set of lines opens the second group:
Set objNavFolder = objGroup.NavigationFolders.Item(2)
DoEvents
objNavFolder.IsSelected = True
objNavFolder.IsSideBySide = False
DoEvents
if the calendars are all in that group, they should open, otherwise, copy those lines and change the group #.
if they aren't in the same group, then you can merge parts of the first macro with this.
max says
Diane,
sorry this is the correct question. ignore previous.
thanks for the writeup. have been using for a while. outlook must have auto-updated. now get a compile error on
Set objCalendar = Session.GetDefaultFolder(olFolderCalendar)
error = obect library feature not supported.
an you help ? thanks
max says
Diane,
thanks for the writeup. have been using for a while. outlook must have auto-updated. now get a compile error on
Set objModule = objPane.Modules.GetNavigationModule(olModuleCalendar)
error = obect library feature not supported.
an you help ? thanks
Lane Jacobs says
Hey Diane!
How might this look different if I wanted to select a calendar based on its name?
Thanks!
Diane Poremsky says
you can replace the index number with a name but if it's not in the default group you need to set the group it's in.
With objModule.NavigationGroups
' Set objGroup = .GetDefaultNavigationGroup(olMyFoldersGroup)
Set objGroup = .Item("group name")
End With
Set objNavFolder = objGroup.NavigationFolders.Item("Alpha")
objNavFolder.IsSelected = True
objNavFolder.IsSideBySide = False
Lane says
Sorry to bother again!
I had set the correct group I wanted the code to grab the calendar from - however upon strictly replacing the index number with a name - I received some errors :( Below is the part of code I would have changed.
For i = 1 To objGroup.NavigationFolders.Count
Set objNavFolder = objGroup.NavigationFolders.Item(i)
Select Case i
' Enter the calendar index numbers you want to open
Case Room 01 100
objNavFolder.IsSelected = True
I'm sure I've done something incorrectly, or that I've perhaps misread your instructions. Did I replace the index number with the name incorrectly?
Thorsten says
Dear Diane, thanks for this script. If i put Outlook in Autostart with the start-view on calendar it is starting with the users calendar and not the one set in case x. Only after manually starting the makro it is on the correct one. Do you have an idea?
Diane Poremsky says
Try the macro here - show the correct calendar on start
Eric says
Oops, I just noticed that Johan Verdouw had a similar request. I'm not sure if there's a material difference between the fact that his two windows start up both upon starting the Outlook executable, versus my three windows starting up by invoking Outlook three separate times. Also, totally inexperienced with macros, so if you could be explicit in how the macros should be modified, that would be very helpful. Thanks!
Diane Poremsky says
i'll need to test the macros - i'm not sure its possible, but will check.
Eric says
Diane, Thanks for the great help. I have a slightly different problem I'm trying to solve which I think will be easy for you to solve. I like to start Outlook with Inbox, Calendar and Contacts all open as separate Windows. The only way I found to do this is with a batch file, calling Outlook three separate times. It looks like this.
timeout /t 1
cd "C:\Program Files\Microsoft Office 15\root\office15"
timeout /t 1
start OUTLOOK.EXE /select "Outlook:\foo@bar.com\search folders\conversation" /profile work
timeout /t 1
cd "C:\Program Files\Microsoft Office 15\root\office15"
timeout /t 1
start OUTLOOK.EXE /select "Outlook:\foo@bar.com\calendar" /profile work
timeout /t 1
cd "C:\Program Files\Microsoft Office 15\root\office15"
timeout /t 1
start OUTLOOK.EXE /select "Outlook:\foo@bar.com\contacts" /profile work
timeout /t 1
The timeout lines aren't elegant, but the script seemed to be stepping on itself without them, preventing all three Windows from launching. With the timeout lines, it works every time. And, the combination of 'cd' followed by 'start' doesn't seem elegant either, but it works, and I couldn't find any other way. Also, the /profile switch may not be needed for most people, but I need it because I have a person profile for my Yahoo account, and a work profile with my corporate Exchange account.
A word of warning first. I have never played with macros until I copy and pasted the "Automatically select specific calendars when switching to the calendar module". I signed it using your "https://www.slipstick.com/developer/how-to-use-outlooks-vba-editor/" article. It worked like a charm. Thanks!
Now, I have your macro working, so if I start a single Outlook in Inbox, then move to Calendar view using the navigation icons in the bottom left of my Outlook window, the macro runs and all three of my calendars are selected and shown. But with my batch file, I don't ever select that navigation icon. The Calendar window is automatically started and the macro is not run. Interestingly enough, when I'm in that automatically opened calendar window, when I navigate to Inbox, then back to Calendar, the macro does not run, or at least the multiple calendars are not opened. But if I close the Calendar window, then go to the automatically opened Contacts or Inbox window, then click the icon to navigate to Calendar, the macro is run and all three calendars are selected and show.
How do I get the macro to run upon opening Outlook?
Diane Poremsky says
I'm not sure you can... the issues you have with it the secondary windows is something I'm aware of, but at this time I don't have a solution.
If you open all 3 windows then Exit using the File, Exit command in the first Window, don't all 3 windows reopen? It won't fix the macro problem, but will eliminate the need for the batch file.
Johan Verdouw says
Dear Diane,
Thanks for providing your example code.
I am trying to implement your code for automatically selecting multiple Calendars at startup. I work with Outlook 2013. I always work with two windows in Outlook: one is Mail (Inbox) and the other is my Calendar. I close Outlook always from the Inbox window and consequently every time when I start Outlook, both windows are automatically opened. Your code is only applied to my Inbox window though and since I never change the navigation pane to Calendar, it does not work for me.
I tried adding some lines of code to your example using the Inspectors object (I am a Dutch user, hence the word 'Agenda' for Calendar):
Dim iExplorers As Integer
Dim iCounter As Integer
Dim strCaption As String
iExplorers = Application.Explorers.count
If iExplorers > 1 Then
For iCounter = 1 To iExplorers
strCaption = Application.Explorers.Item(iCounter).Caption
If Left(strCaption, 6) = "Agenda" Then
Set objPane = Application.Explorers.Item(iCounter).NavigationPane
Exit Sub
End If
Next iCounter
End If
This does not work however since the Startup code is run BEFORE the second window (with Calendar) is opened.
Any ideas on how to make it work anyway?
Johan
Diane Poremsky says
I will look into it, but I'm not sure it will work because you are using two windows. We might be able to check the windows name and run it if the name matches though.
Diane Poremsky says
This code gets the main outlook window's names (not open message names) - so, you just need to make sure you're working in the correct explorer when the code runs. Will probably need to activate the window then make the other one active when its done - will result in a quick flash on the screen most likely.
Sub ListWindows()
Dim wn As Outlook.Explorer
For Each wn In Application.Explorers
Debug.Print wn.Caption
Next wn
End Sub
Amanda says
Dear Diane
I have a query - sorry if it is a basic one as I am new to this! I have successfully copied this code for automatically selecting calenders into the ThisOutlookSession module. It appears to work as suggested when I start up outlook and switch from my mail folder to the calender folder. However, if I right click on calender and select open in a new window it only opens my default calender. The same thing happens if, for example, I switch from contacts to calender in another outlook window (i.e. not the main one that opens at the start up). As I tend to have multiple outlook windows open at any one time this isn't ideal.
Is there a way that I can tweak the code to ensure that no matter how I open the calender it will always show all three selected and not just the default? Or have I done something wrong (i.e. should it already be doing this?!).
Thanks in advance for your advice
Amanda
Amanda says
p.s. I am using outlook 2010
Diane Poremsky says
I'll look into it - but I'd expect it would work as you want due to this line:
Set objPane = Application.ActiveExplorer.NavigationPane
But there may be something 'special' about new windows. I'll see what I can find out.
jan.kempeneers2@gmail.com says
Hi,
I have the same thing happening and thus am looking for the same solution.
It would be great to hear whether a solution has been found.
I am new to VBA but might it be because the "Private Sub objPane_ModuleSwitch" is only fired by an event that comes only from the navigation pane and that there are other ways to get to calendar view than through the navigation pane?
Regards,
Jan.
Joel says
Diane,
Please Help. I am trying to select and unselect calendars from multiple groups using multiple macros. Can this be done?
Thanks,
Diane Poremsky says
It can be done - you'll repeat the With navigationgroups and the For i = 1 to count blocks for each group that contains calendars you want to select or deselect.
With objModule.NavigationGroups
Set objGroup = .Item("Other Calendars")
End With
For i = 1 To objGroup.NavigationFolders.Count
Set objNavFolder = objGroup.NavigationFolders.Item(i)
Select Case i
' if you want to deselect calendars in this group, do it first
Case 1, 5
objNavFolder.IsSelected = False
' Enter the calendar index numbers you want to open
Case 3, 4, 7
objNavFolder.IsSelected = True
' Set to True to open side by side
objNavFolder.IsSideBySide = False
Case Else
objNavFolder.IsSelected = False
End Select
Next
Krasimir says
Diane,
Need help. I cant get an internet published calendar to sync with my private Outlook 13. When I publish it from my company Exchange account all goes well, I log in with my outlook.com account, send invitation to my private email and open the link on my private pc. It retrieves for a while and disappears.. Says "check validity of the link.." Actually all worked till two days ago and when I noticed an error in send/receive just deleted the previous subscription and created a new one. Any idea where the issue is?
Thanks,
Diane Poremsky says
So you are publishing an Exchange calendar and inviting an Outlook.com address? Does it seem to publish ok? It's possible the admin is blocking it at the firewall.