1

I've got some VBa code that opens the Calendar in a new window, but I now need it to display the shared calendars that I've already got setup, but the only code I can find Creates a new shared calendar in the new window i've just created;

Sub DispCalendars()
    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.Application")

    Set myNms = myOlApp.GetNamespace("MAPI")
    Set myFolder = myNms.GetDefaultFolder(olFolderCalendar)

    Set myExplorer = myOlApp.ActiveExplorer
    Set myExplorer.CurrentFolder = myFolder
    Set myRecipient = myNms.CreateRecipient("Bob the Builder")
    Set SharedFolder = myNms.GetSharedDefaultFolder(myRecipient, olFolderCalendar)
    myExplorer.SelectFolder SharedFolder
End Sub

If I change to 'myRecipient' part to just a name, it errors and I can't seem to work it out.

Here is something how it looks (when I do it manually) and I would like to recreate it in code.

1
  • So the problem is that GetSharedDefaultFolder returns an error for a particular name? What is the exact error? Can Outlook resolve it if you type the same value in the To edit box and hit Ctrl+K? Nov 22, 2013 at 16:53

1 Answer 1

1

I think you miss the line to show the Folder selected in Outlook

    myExplorer.CurrentFolder = SharedFolder 

i guess instead of the "selectfolder"-line... also some of the other lines could be deleted, espacially

Set myExplorer.CurrentFolder = myFolder

as it does not make sende to open two Folders one after another in one Sub.

Yours Max

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.