CAGreenlaw
asked on
Open a non-default shared calendar in Oulook using VBA
I'm trying to open a non-default shared calendar in Outlook using VBA but I only know how to open the default one. I have spent a considerable amount of time researching this online but no luck. Any help would be greatly appreciated.
The user name of the shared calendar is "John Burns" and the non-default calendar name is "Van".
My code to retrieve the default shared calendar is :
Dim myOlApp As Outlook.Application
Dim myNms As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myRecipient As Outlook.Recipient
Dim myExplorer As Outlook.Explorer
Dim SharedFolder As Outlook.MAPIFolder
Set myOlApp = CreateObject("Outlook.Appl ication")
Set myNms = myOlApp.GetNamespace("MAPI ")
Set myFolder = myNms.GetDefaultFolder(olF olderCalen dar)
Set myExplorer = myOlApp.ActiveExplorer
Set myExplorer.CurrentFolder = myFolder
Set myRecipient = myNms.CreateRecipient("Joh n Burns")
Set SharedFolder = myNms.GetSharedDefaultFold er(myRecip ient, olFolderCalendar)
myExplorer.SelectFolder SharedFolder
The user name of the shared calendar is "John Burns" and the non-default calendar name is "Van".
My code to retrieve the default shared calendar is :
Dim myOlApp As Outlook.Application
Dim myNms As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myRecipient As Outlook.Recipient
Dim myExplorer As Outlook.Explorer
Dim SharedFolder As Outlook.MAPIFolder
Set myOlApp = CreateObject("Outlook.Appl
Set myNms = myOlApp.GetNamespace("MAPI
Set myFolder = myNms.GetDefaultFolder(olF
Set myExplorer = myOlApp.ActiveExplorer
Set myExplorer.CurrentFolder = myFolder
Set myRecipient = myNms.CreateRecipient("Joh
Set SharedFolder = myNms.GetSharedDefaultFold
myExplorer.SelectFolder SharedFolder
ASKER
Thanks so much for your quick response BlueDevilFan. I'm not sure how to make this code work for me though (ie. How do I determine the path to the other user's calendar?). I'm trying to open a shared non-default calendar that hasn't already been added to my profile. I think I need to utilize the GetSharedDefaultFolder method but it only returns the default calendar from the user. The other user has several calendars and I need to pick the one called Van and open it. Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Wow, you really know your stuff BlueDevilFan. Thank you so much, it worked like a charm!
You're welcome, CAGreenlaw. Glad I could help out.
You can use the following function to open any Outlook folder, default or otherwise. Here's how to call it
Set myFolder = OpenOutlookFolder("Path to the folder you want to open")
Open in new window