CalendarSharing.SaveAsICal メソッド (Outlook)

CalendarSharing オブジェクトの親 Folder オブジェクトの予定表の情報を iCalendar カレンダー (.ics) ファイルとしてエクスポートします。

構文

SaveAsICal( _Path_ )

CalendarSharing オブジェクトを返す式。

パラメーター

名前 必須 / オプション データ型 説明
パス 必須 String iCalendar ファイルのパスとファイル名を指定します。

注釈

ICalendar ファイルに記載されている詳細のレベルは、次の エクスポート のプロパティの値の組み合わせによって決定されます。

IncludeWholeCalendar プロパティを設定するには true を指定 のフォルダーに含まれるすべてのアイテムをエクスポートするのにはまたは、指定した開始日との間の日付範囲をエクスポートした項目数を制限し、それぞれの終了日、 開始日終了日 のプロパティを設定することができます。

次の Visual Basic for Applications (VBA) の例は、予定表フォルダーの エクスポート オブジェクトを作成し、全体のフォルダーを (添付ファイルやプライベートなアイテムを含む) の内容を iCalendar カレンダー (.ics) ファイルにエクスポートします。

Public Sub ExportEntireCalendar() 
 
 
 
 Dim oNamespace As NameSpace 
 
 Dim oFolder As Folder 
 
 Dim oCalendarSharing As CalendarSharing 
 
 
 
 On Error GoTo ErrRoutine 
 
 
 
 ' Get a reference to the Calendar default folder 
 
 Set oNamespace = Application.GetNamespace("MAPI") 
 
 Set oFolder = oNamespace.GetDefaultFolder(olFolderCalendar) 
 
 
 
 ' Get a CalendarSharing object for the Calendar default folder. 
 
 Set oCalendarSharing = oFolder.GetCalendarExporter 
 
 
 
 ' Set the CalendarSharing object to export the contents of 
 
 ' the entire Calendar folder, including attachments and 
 
 ' private items, in full detail. 
 
 With oCalendarSharing 
 
 .CalendarDetail = olFullDetails 
 
 .IncludeWholeCalendar = True 
 
 .IncludeAttachments = True 
 
 .IncludePrivateDetails = True 
 
 .RestrictToWorkingHours = False 
 
 End With 
 
 
 
 ' Export calendar to an iCalendar calendar (.ics) file. 
 
 oCalendarSharing.SaveAsICal "C:\SampleCalendar.ics" 
 
 
 
EndRoutine: 
 
 On Error GoTo 0 
 
 Set oCalendarSharing = Nothing 
 
 Set oFolder = Nothing 
 
 Set oNamespace = Nothing 
 
Exit Sub 
 
 
 
ErrRoutine: 
 
 Select Case Err.Number 
 
 Case 287 ' &H0000011F 
 
 ' The user denied access to the Address Book. 
 
 ' This error occurs if the code is run by an 
 
 ' untrusted application, and the user chose not to 
 
 ' allow access. 
 
 MsgBox "Access to Outlook was denied by the user.", _ 
 
 vbOKOnly, _ 
 
 Err.Number & " - " & Err.Source 
 
 Case -2147467259 ' &H80004005 
 
 ' Export failed. 
 
 ' This error typically occurs if the CalendarSharing 
 
 ' method cannot export the calendar information because 
 
 ' of conflicting property settings. 
 
 MsgBox Err.Description, _ 
 
 vbOKOnly, _ 
 
 Err.Number & " - " & Err.Source 
 
 Case -2147221233 ' &H8004010F 
 
 ' Operation failed. 
 
 ' This error typically occurs if the GetCalendarExporter method 
 
 ' is called on a folder that doesn't contain calendar items. 
 
 MsgBox Err.Description, _ 
 
 vbOKOnly, _ 
 
 Err.Number & " - " & Err.Source 
 
 Case Else 
 
 ' Any other error that may occur. 
 
 MsgBox Err.Description, _ 
 
 vbOKOnly, _ 
 
 Err.Number & " - " & Err.Source 
 
 End Select 
 
 
 
 GoTo EndRoutine 
 
End Sub

関連項目

オブジェクトのエクスポート

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。