我正在尝试将日历信息从“Markdown Calendar”(已订阅的日历)提取到 Excel 中。
这是一个在线日历,与我的默认位置不在同一位置。
我在网上找到的代码是从我自己的日历中提取的。
如何将
GetDefaultFolder
更改为Markdown日历?
Sub Markdown_Calendar()
Dim olApp As Object
Dim olNS As Object
Dim olFolder As Object
Dim olApt As Object
Dim NextRow As Long
Dim olFolderNew As Object
Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set olFolder = olNS.GetDefaultFolder(9)
Range("A1:D1").Value = Array("Subject", "Start", "End", "Location")
NextRow = 2
For Each olApt In olFolder.Items
Cells(NextRow, "A").Value = olApt.Subject
Cells(NextRow, "B").Value = olApt.Start
Cells(NextRow, "C").Value = olApt.End
Cells(NextRow, "D").Value = olApt.Location
NextRow = NextRow + 1
Next olApt
Set olApt = Nothing
Set olFolder = Nothing
Set olNS = Nothing
Set olApp = Nothing
Columns.AutoFit
End Sub
您可能会发现 NameSpace.GetSharedDefaultFolder 方法很有用,它用于委派场景,其中一个用户将其一个或多个默认文件夹(例如,他们的共享日历文件夹)的访问权限委派给另一用户。
您还可以获取默认日历文件夹(或父文件夹)并尝试迭代所有子文件夹以找到所需的文件夹。或者只是浏览 Outlook 中的文件夹树,例如:
OutlookApp.Session.Folders(yourDefaultStore.DisplayName).Folders("Calendar Name")