我想做的是:
代码是:
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?