共用方式為


RecurrencePattern.Exceptions 屬性 (Outlook)

返回指定一系列定期任命的 例外 集合。 唯讀。

語法

expressionExceptions

一個代表 RecurrencePattern 物件的變數。

註解

當你處理定期約會項目時,應該先釋出任何先前的參考資料,並在存取或修改該項目前取得新的定期預約項目,並在完成且儲存變更後立即釋出這些參考資料。 此做法適用於重複出現的 AppointmentItem 物件,以及任何 ExceptionRecurrencePattern 物件。 若要在 Visual Basic for Applications (VBA) 或 Visual Basic 中釋出參考,請將該現有物件設為 Nothing。 在 C# 中,明確釋放該物件的記憶體。 關於程式碼範例,請參閱 AppointmentItem 物件的主題。

請注意,即使你解除參考並嘗試取得新的參考,如果仍有其他外掛或 Outlook 持有的有效參考,該物件仍會指向該物件的過期副本。 因此,完成定期約診後,盡快公開推薦信非常重要。

範例

這個 Visual Basic for Applications (VBA) 範例使用 CreateItem 來建立 AppointmentItem 物件。 此項目的 RecurrencePattern 是透過 GetRecurrencePattern 方法取得的。 在設定 RecurrencePattern 屬性、RecurrenceTypePatternStartDatePatternEndDate 後,這些約會現在成為一系列每日發生且為期一年的週期性約會。

當使用 GetOccurrence 方法取得此定期任命的一個實例時,會建立一個例外物件,並改變該實例的屬性。 此例外是透過 GetRecurrencePattern 方法取得,以存取與該系列相關的 例外 集合。 訊息框會顯示此例外的原始 主旨原始日期 ,以及本例外的當前日期、時間與主旨。

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

另請參閱

RecurrencePattern 物件

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應