AppointmentItem.GetRecurrencePattern メソッド (Outlook)

予定の定期的な設定を表す RecurrencePattern オブジェクトを返します。

構文

GetRecurrencePattern

AppointmentItem オブジェクトを表す変数。

戻り値

予定の定期的な設定を表す RecurrencePattern オブジェクト。

注釈

定期的なパターンが存在しない場合は、新しい空の RecurrencePattern オブジェクトを返します。

定期的な予定アイテムの作業を行うときは、以前の参照を解放し、定期的な予定アイテムへの新しい参照を取得してからアイテムにアクセスしたりアイテムを変更したりした後、作業が終了して変更を保存したら直ちに参照を解放する必要があります。 このような方法を適用するのは、定期的な AppointmentItem オブジェクト、およびすべての Exception または RecurrencePattern オブジェクトです。 Visual Basic for Applications (VBA) または Visual Basic で参照を解放するには、既存のオブジェクトを Nothing に設定します。 C# では、そのオブジェクトのメモリを明示的に解放します。 コードの例については、 AppointmentItem オブジェクトのトピックを参照してください。

参照を解放してから新しい参照を取得しようとしても、前記のいずれかのオブジェクトに対して、別のアドインまたは Outlook が保持するアクティブな参照がまだある場合、新しい参照はオブジェクトの古いコピーをまだ指していることに注意してください。 したがって、定期的な予定の作業が終了したら速やかに参照を解放することが重要です。

次の Visual Basic for Applications (VBA) の例は、 CreateItem メソッドを使って AppointmentItem オブジェクトを作成します。 この例では、 GetRecurrencePattern メソッドを使って、このアイテムに対する RecurrencePattern オブジェクトを取得します。 次に、 RecurrencePattern オブジェクトの RecurrenceType プロパティ、 PatternStartDate プロパティ、および PatternEndDate プロパティを設定し、1 年間毎日繰り返される定期的な予定にします。

定期的な予定の 1 つを GetOccurrence メソッドを使って取得し、プロパティを変更すると、 Exception オブジェクトが作成されます。 このようにして作成された定期的な予定の例外を取得するには、定期的な予定に関連付けられている Exceptions コレクションを GetRecurrencePattern メソッドで操作します。 メッセージ ボックスには、例外の元の Subject プロパティと OriginalDate プロパティのほかに、この例外の件名と現在の日時が表示されます。

Public Sub cmdExample() 
 
 Dim myApptItem As Outlook.AppointmentItem 
 
 Dim myRecurrPatt As Outlook.RecurrencePattern 
 
 Dim myNamespace As Outlook.NameSpace 
 
 Dim myFolder As Outlook.Folder 
 
 Dim myItems As Outlook.Items 
 
 Dim myDate As Date 
 
 Dim myOddApptItem As Outlook.AppointmentItem 
 
 Dim saveSubject As String 
 
 Dim newDate As Date 
 
 Dim myException As Outlook.Exception 
 
 
 
 Set myApptItem = Application.CreateItem(olAppointmentItem) 
 
 myApptItem.Start = #2/2/2003 3:00:00 PM# 
 
 myApptItem.End = #2/2/2003 4:00:00 PM# 
 
 myApptItem.Subject = "Meet with Boss" 
 
 
 
 'Get the recurrence pattern for this appointment 
 
 'and set it so that this is a daily appointment 
 
 'that begins on 2/2/03 and ends on 2/2/04 
 
 'and save it. 
 
 Set myRecurrPatt = myApptItem.GetRecurrencePattern 
 
 myRecurrPatt.RecurrenceType = olRecursDaily 
 
 myRecurrPatt.PatternStartDate = #2/2/2003# 
 
 myRecurrPatt.PatternEndDate = #2/2/2004# 
 
 myApptItem.Save 
 
 
 
 'Access the items in the Calendar folder to locate 
 
 'the master AppointmentItem for the new series. 
 
 Set myNamespace = Application.GetNamespace("MAPI") 
 
 Set myFolder = myNamespace.GetDefaultFolder(olFolderCalendar) 
 
 Set myItems = myFolder.Items 
 
 Set myApptItem = myItems("Meet with Boss") 
 
 
 
 'Get the recurrence pattern for this appointment 
 
 'and obtain the occurrence for 3/12/03. 
 
 myDate = #3/12/2003 3:00:00 PM# 
 
 Set myRecurrPatt = myApptItem.GetRecurrencePattern 
 
 Set myOddApptItem = myRecurrPatt.GetOccurrence(myDate) 
 
 
 
 'Save the existing subject. Change the subject and 
 
 'starting time for this particular appointment 
 
 'and save it. 
 
 saveSubject = myOddApptItem.Subject 
 
 myOddApptItem.Subject = "Meet NEW Boss" 
 
 newDate = #3/12/2003 3:30:00 PM# 
 
 myOddApptItem.Start = newDate 
 
 myOddApptItem.Save 
 
 
 
 'Release references to the appointment series 
 
 Set myApptItem = Nothing 
 
 Set myRecurrPatt = Nothing 
 
 
 
 'Get the recurrence pattern for the master 
 
 'AppointmentItem. Access the collection of 
 
 'exceptions to the regular appointments. 
 
 Set myItems = myFolder.Items 
 
 Set myApptItem = myItems("Meet with Boss") 
 
 
 
 Set myRecurrPatt = myApptItem.GetRecurrencePattern 
 
 Set myException = myRecurrPatt.Exceptions.Item(1) 
 
 
 
 'Display the original date, time, and subject 
 
 'for this exception. 
 
 MsgBox myException.OriginalDate & ": " & saveSubject 
 
 
 
 'Display the current date, time, and subject 
 
 'for this exception. 
 
 MsgBox myException.AppointmentItem.Start & ": " & _ 
 
 myException.AppointmentItem.Subject 
 
End Sub

関連項目

AppointmentItem オブジェクト

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

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