引用共享日历

问题描述:

我试图从以下问题运行代码: 将Outlook日历数据导出到Excel文件-共享日历和VBA

I tried to run the code from this question: Exporting Outlook calendar data to Excel file - Shared calendars and VBA

我的代码修改.

Set olNS = olApp.GetNamespace("MAPI")
Set myCalItems = olNS.CreateRecipient("theOtherUser")
myCalItems.Resolve
myCalItems.GetSharedDefaultFolder 

我收到错误13类型不匹配的错误.我已经测试了不同的组合,但没有结果.

I got error 13 Type mismatch. I've testing different combinations without result.

我也测试了这个例子: MSDN链接

I tested this example too: MSDN link

此信息有用但还不够: http://www.snb-vba .eu/

This info is useful but not enough: http://www.snb-vba.eu/

我需要将共享的MS Outlook的日历(与Exchange服务器一起)导出到MS Excel.

I need to export shared MS Outlook's calendars (with Exchange server) to MS Excel.

这些日历共享给我和其他人.

These calendars are shared to me and other people.

我运行MS Office 2010版本.

I run MS Office 2010 version.

VBA中的错误13表示类型不匹配.请参见类型不匹配(错误13)有关更多信息.

Error 13 in VBA means a type mismatch. See Type mismatch (Error 13) for more information.

您需要改用以下代码:

Sub ShowSharedFolder(OutlookApplication As Outlook.Application) 
   Dim myNamespace As Outlook.NameSpace 
   Dim myRecipient As Outlook.Recipient 
   Dim CalendarFolder As Outlook.Folder 

   Set myNamespace = OutlookApplication.GetNamespace("MAPI") 
   Set myRecipient = myNamespace.CreateRecipient("theOtherUser") 
   myRecipient.Resolve 

   If myRecipient.Resolved Then 
     Set CalendarFolder = myNamespace.GetSharedDefaultFolder(myRecipient, olFolderCalendar) 
     CalendarFolder.Display 
   End If 
End Sub