使用VBA在Outlook 2016中重命名NavigationFolder

时间:2018-01-20 07:29:28

标签: vba outlook outlook-vba outlook-2016

我想做的是:

  1. 创建新的日历组
  2. 获取共享日历并加入1。
  3. 重命名共享日历
  4. 代码是:

    Dim outlookObj As Outlook.Application
    Dim namespaceObj As NameSpace
    Dim recipientObj As Outlook.recipient
    Dim paneObj As Outlook.NavigationPane
    Dim moduleObj As Outlook.CalendarModule
    Dim navGroupObj As Outlook.NavigationGroup
    Dim navFolderObj As Outlook.NavigationFolder
    Dim folderObj As Folder
    
    'Create a recipient "John Smith"
    Set outlookObj = CreateObject("Outlook.Application")
    Set namespaceObj = outlookObj.GetNamespace("MAPI")
    Set recipientObj = namespaceObj.CreateRecipient("John Smith")
    
    'Create a new calendar group
    Set paneObj = Application.ActiveExplorer.NavigationPane
    Set moduleObj = paneObj.Modules.GetNavigationModule(olModuleCalendar)
    Set navGroupObj = moduleObj.NavigationGroups.Create("NewCalendarGroup")
    
    If(recipientObj.Resolved) Then
        'Add a shared calendar into "NewCalendarGroup"
        Set folderObj = namespaceObj.GetSharedDefaultFolder(recipientObj, olFolderCalendar)
        Set navFolderObj = navGroupObj.NavigationFolders.Add(folderObj)
    
        'Rename the shared calendar
        navFolderObj.DisplayName = "John's calendar"  'error
    End If
    

    但是,由于NavigationFolder.DisplayName是只读的,因此Outlook在此行显示错误:

    'Rename the shared calendar
    navFolderObj.DisplayName = "John's calendar"  'error
    

    我可以右键单击日历并在屏幕上重命名,但是如何使用VBA执行相同的操作?有没有办法更改只读的DisplayName?

0 个答案:

没有答案