2017-04-13 63 views
0

我试图逃避这个问题的代码: 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类型不匹配。我测试了不同的组合,没有结果。

我测试了这个例子太: MSDN link

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

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

这些日历分享给我和其他人。

我运行MS Office 2010版本。

+0

可能你合理地宣布myCalItems作为项目的名称建议。在你的代码中myCalItems是别的。 http://stackoverflow.com/help/mcve – niton

+0

你用什么? Excel或Outlook -vba? – 0m3r

+0

嗨!我正在使用excel vba –

回答

0

VBA中的错误13意味着类型不匹配。有关更多信息,请参阅Type mismatch (Error 13)

您需要使用下面的代码来代替:

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 
+0

到目前为止,您的代码工作。 我在线得到了新的错误:myCalItems.Sort“START”,False。 <<“START”属性未知。 >> –

+0

这是另一回事。但你需要使用'开始'而不是我的比尔。 –

+0

感谢您的回答。 我是新来的。你知道我是否必须在这个问题上提出一个新的问题? –