Outlook 2013 VBA display Shared Calendar

只愿长相守 提交于 2019-12-11 09:25:52

问题


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:


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



来源:https://stackoverflow.com/questions/20141659/outlook-2013-vba-display-shared-calendar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!