私はMS Outlook 2013 VBA(MS Exchange)を使用して会社の会議室カレンダーイベントを読み込もうとしています。私のスクリプトは書き込み権限があるカレンダーだけで動作しますが、会議室の共有カレンダーは読み取り専用です。スクリプトを試してみると、ランタイムエラー '-2147221233(8004010f)'が出ます。Outlook VBAオープン読み取り専用共有交換カレンダー
Sub ShowOtherUserCalFolders()
Dim namespace As Outlook.namespace
Dim recipient As Outlook.recipient
Dim CalendarFolder As Outlook.Folder
Set namespace = Application.GetNamespace("MAPI")
Set recipient = namespace.CreateRecipient("calendar-name")
recipient.Resolve
MsgBox recipient.Name
'The name is shown correctly
If recipient.Resolved Then
Set CalendarFolder = namespace.GetSharedDefaultFolder(recipient, olFolderCalendar)
'This should display the calendar on the screen, but it fails
CalendarFolder.Display
Dim oItems As Outlook.Items
Set oItems = CalendarFolder.Items
'The oItems is empty when trying to use read-only calendar
MsgBox oItems.Count
End If
End Sub
読み取り専用共有カレンダーから情報を取得する正しい方法はありますか?
namespaceからtopfolderのフォルダツリーを "calendar-name"のサブフォルダに移動します。https://stackoverflow.com/a/9077144 – niton