Share via


Open Shared Calendars with VBA

Question

Friday, January 26, 2018 9:15 PM

I'm looking to open a number of shared calendars at the open of outlook in Week view.  I can get some VBA to open the calendars individually, but they all need to be in one session listed in week view. 

Basically get it to open outlook calendar and then check the boxes for the shared calendars I have listed.

Please advise.

All replies (4)

Wednesday, January 31, 2018 9:23 AM âś…Answered | 1 vote

Hello NoSwanky,

I would suggest you refer to below code for testing.

Sub SelectAllSharedCalendars()
    Dim olPane As NavigationPane
    Dim olMod As CalendarModule
    Dim olGrp As NavigationGroup
    Dim olNavFld As NavigationFolder
    Dim olCalFld As Folder
    
    Set Application.ActiveExplorer.CurrentFolder = Session.GetDefaultFolder(olFolderCalendar)
    Set olCalFld = Session.GetDefaultFolder(olFolderCalendar)
    Set olPane = Application.ActiveExplorer.NavigationPane
    Set olMod = olPane.Modules.GetNavigationModule(olModuleCalendar)
    Set olGrp = olMod.NavigationGroups.Item("Shared Calendars")
   
    For i = 1 To olGrp.NavigationFolders.Count
        Set olNavFld = olGrp.NavigationFolders.Item(i)
        olNavFld.IsSelected = True
    Next

End Sub

Best Regards,

Terry

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Monday, January 29, 2018 2:56 AM

Hi,

Welcome to the Microsoft Office for IT Professionals Outlook forum. This forum is for non-programming questions related to Microsoft Outlook. Since your request is more related to VBA, I'll move it to a more appropriate forum:

https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=outlookdev

The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

Regards,

Steve Fan

Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact [email protected].


Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.


Monday, February 12, 2018 8:41 PM

That worked well, I'd like to have it close any other calendars before opening the others.  Would you have any advice on how to do that?

In particular the "My Calendars" - "Calendar" opens by default.

Additionally, I need it to open to next weeks calendar every time it opens.  so if it opens on Friday, I want it to be showing next week Sunday - Saturday.


Thursday, February 15, 2018 4:44 PM

Hey Terry,

I'm wondering if you could help me modify the code slightly.  It's doing what we need initially, however, it need to close the default "My Calendar", additionally I need it to open to the next week.