2017-04-13 60 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

感謝您的回答。 我是新來的。你知道我是否必須在這個問題上提出一個新的問題? –