2017-12-12 17 views
0

私は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 

読み取り専用共有カレンダーから情報を取得する正しい方法はありますか?

+0

namespaceからtopfolderのフォルダツリーを "calendar-name"のサブフォルダに移動します。https://stackoverflow.com/a/9077144 – niton

答えて

0

該当するフォルダにフォルダツリーを移動できます。

Option Explicit 

Sub ShowOtherUserCalFolders1() 

    Dim CalendarFolder As Folder 
    Dim oItems As items 
    Dim currFolder_entryID As String 

    ' Walk the folder tree to the applicable folder 

    ' Right click on folder | Properties 
    ' General Tab | Location 
    ' \\Highest level name of shared Boardrooms\subfolder 

    Set CalendarFolder = Session.folders("Highest level name of shared Boardrooms") 
    Set CalendarFolder = CalendarFolder.folders("subfolder") 
    Set CalendarFolder = CalendarFolder.folders("boardroom name") 

    Set ActiveExplorer = CalendarFolder 
    Set oItems = CalendarFolder.items 
    MsgBox CalendarFolder & " has " & oItems.count & " items" 

End Sub 
0

あなたはentryIDで直接会議室を参照できます。

Option Explicit 

Sub ShowOtherUserCalFolders2() 

    Dim CalendarFolder As Folder 
    Dim oItems As items 
    Dim currFolder_entryID As String 

    ' Reference the boardroom directly with entryID 
    ' Open the applicable calendar 

    ' In the immediate pane 
    ' ?ActiveExplorer.CurrentFolder.EntryID 
    ' or 
    Debug.Print ActiveExplorer.CurrentFolder.EntryID 

    ' Once you know the entryID, hardcode and uncomment 
    'currFolder_entryID = "entryID shown in the immediate pane" 

    'Set CalendarFolder = Session.GetFolderFromID(currFolder_entryID) 

    'Set ActiveExplorer = CalendarFolder 
    'Set oItems = CalendarFolder.items 
    'MsgBox "" & CalendarFolder & " has " & oItems.count & " items" 

End Sub 
関連する問題