Opening Shared folder in new window using vba

ian orr 1 Reputation point
2021-12-04T22:44:51.12+00:00

Hello All,
I am trying to open a shared calendar in a new window and I can't quite seem to figure out how to get it done. Information on Outlook VBA is somewhat scarce. I need to be able to open a specific shared calendar of my choice in a new window, but getting a new window to do anything for me is very difficult. I have a couple of links that I am trying to use to work off of but what i have scrapped together is below. I have used Excel VBA for a while now, but this is my first time using it for Outlook so there are a lot of tricks I am not familiar with yet, so thanks for any help.

links:
https://social.msdn.microsoft.com/Forums/office/en-US/f1d94df0-1bab-4ddb-9d9d-61d3d56fba5d/open-outlook-folder-in-new-window?forum=outlookdev
https://social.msdn.microsoft.com/Forums/en-US/c56e1032-7375-45a4-98de-ac1c00a7464c/open-shared-calendars-with-vba?forum=outlookdev
https://www.slipstick.com/developer/code-samples/select-multiple-calendars-outlook/

Sub SelectCalendars()
Dim objPane As Outlook.NavigationPane
Dim objModule As Outlook.CalendarModule
Dim objGroup As Outlook.NavigationGroup
Dim objNavFolder As Outlook.NavigationFolder
Dim F As Outlook.MAPIFolder
Dim objCalendar As Folder
Dim objFolder As Folder

Dim i As Integer

SharedUser = "Shared User"

Set Application.ActiveExplorer.CurrentFolder = Session.GetFolder(olFolderCalendar)
DoEvents

Set objCalendar = Session.GetDefaultFolder(olFolderCalendar)
objCalendar.Display
Set objPane = Application.ActiveExplorer.NavigationPane
Set objModule = objPane.Modules.GetNavigationModule(olModuleCalendar)

With objModule.NavigationGroups
    Set objGroup1 = .GetDefaultNavigationGroup(olMyFoldersGroup)

' To use a different group
    Set objGroup2 = .Item("Other Calendars")
End With

For i = 1 To objGroup2.NavigationFolders.Count
    Set objNavFolder = objGroup2.NavigationFolders.Item(i)
    If  objNavFolder = SharedUser Then
            objNavFolder.IsSelected = True
    Else      'I want to deslelect the rest of the folders
            objNavFolder.IsSelected = False
    End if
Next

'trying to close all other calendars
For i = 1 To objGroup1.NavigationFolders.Count
Set objNavFolder = objGroup1.NavigationFolders.Item(i)
objNavFolder.IsSelected = False
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

Outlook Management
Outlook Management
Outlook: A family of Microsoft email and calendar products.Management: The act or process of organizing, handling, directing or controlling something.
5,072 questions
0 comments No comments
{count} votes