[英]Importing Appointments from Outlook
I have a Shared Outlook Appointment calendar that's linked to a colleague's account.我有一个与同事帐户相关联的共享 Outlook 约会日历。 I am trying to export the appointments from that calendar to Excel.我正在尝试将该日历中的约会导出到 Excel。
I found lots of pages of VBA code showing how to export from their main calendar by using their email address in the code however this Calendar has been set up as an appointment calendar only and is separate from the user's main calendar.我发现很多 VBA 代码页面显示了如何使用代码中的 email 地址从主日历导出,但是此日历仅设置为约会日历,并且与用户的主日历分开。 When I reference her email address, it pulls from her main calendar.当我引用她的 email 地址时,它从她的主日历中提取。
The Appointment Calendar was shared by email and I needed to accept to add it to my own calendar lists.约会日历由 email 共享,我需要接受将其添加到我自己的日历列表中。
I guess I need to name this specific calendar in the code?我想我需要在代码中命名这个特定的日历?
When you got a calendar folder you can try to get the parent folder and then iterate over all subfolders along with a shared calendar already retrieved.当您获得日历文件夹时,您可以尝试获取父文件夹,然后遍历所有子文件夹以及已检索的共享日历。 Hope there you will be able to find what you need.希望在那里你能找到你需要的东西。
To get a shared calendar folder you need to use the GetSharedDefaultFolder
method of the Namespace
class which returns a Folder
object that represents the specified default folder for the specified user.要获取共享日历文件夹,您需要使用Namespace
class 的GetSharedDefaultFolder
方法,该方法返回代表指定用户的指定默认文件夹的Folder
object。 This method is used in a delegation scenario, where one user has delegated access to another user for one or more of their default folders (for example, their shared Calendar
folder).此方法用于委派方案,其中一个用户已将一个或多个默认文件夹(例如,他们的共享Calendar
文件夹)的访问权限委派给另一个用户。 For example:例如:
Sub ResolveName()
Dim myNamespace As Outlook.NameSpace
Dim myRecipient As Outlook.Recipient
Dim CalendarFolder As Outlook.Folder
Set myNamespace = Application.GetNamespace("MAPI")
Set myRecipient = myNamespace.CreateRecipient("Eugene Astafiev")
myRecipient.Resolve
If myRecipient.Resolved Then
Call ShowCalendar(myNamespace, myRecipient)
End If
End Sub
Sub ShowCalendar(myNamespace, myRecipient)
Dim CalendarFolder As Outlook.Folder
Set CalendarFolder = _
myNamespace.GetSharedDefaultFolder _
(myRecipient, olFolderCalendar)
CalendarFolder.Display
End Sub
So, after getting the default calendar folder you may ask for the parent folder (see the Parent
property).因此,在获取默认日历文件夹后,您可能会要求提供父文件夹(请参阅Parent
属性)。 Then you can use the Folders property which returns the Folders
collection that represents all the folders contained in the specified Folder.然后,您可以使用Folders属性,该属性返回表示指定文件夹中包含的所有文件夹的Folders
集合。 Iterating over all subfolders you mat find the required one.遍历您需要的所有子文件夹。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.