简体   繁体   中英

Parsing appointments from shared Outlook calendars

I am trying to create an anonymized schedule for the conference rooms on our floor via Excel VBA.

The source data is stored in different Outlook calendars (every room has its own) and I got access to them via the "shared calendar" functionality of Outlook.

The problem I am currently having is fully automating the data retrieval process. I got everything else working fine, however, it requires the user to manually select the (currently) five different calendars from a small pop-up window, which is rather tiresome.

I have tried using the GetDefaultFolder(olFolderCalendar).Items approach, but this only seems to work for the local calendar not shared ones from the network (Exchange).

Is there a way to address these room calendars directly so that I can automate my process?

best regards,

daZza

Here's my current code, cut down to the relevant parts:

Set olNS = olApp.GetNamespace("MAPI")

For x = 1 To 5

    Set myCalItems = olNS.PickFolder.Items

    With myCalItems
        .Sort "[Start]", False
        .IncludeRecurrences = True
    End With

    StringToCheck = "[Start] >= " & Quote(StartDate & " 12:00 AM") & " AND [End] <= " & Quote(EndDate & " 11:59 PM")

    Set ItemstoCheck = myCalItems.Restrict(StringToCheck)

    ' Do stuff with every item in "ItemstoCheck"
    ' ...
    ' ...
    ' ...

Next 

您是否研究过 Namespace.GetSharedDefaultFolder 方法?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM