End 属性

       

返回或设置约会或日记条目的结束日期和时间。Date 类型,可读写。

expression.End

expression   必选。该表达式返回 AppointmentItemJournalItem 对象。

示例

本 Visual Basic for Applications 示例使用 CreateItem 创建 AppointmentItem 对象。使用 GetRecurrencePattern 方法获得该项目的 RecurrencePattern 属性。通过设置 RecurrencePattern 属性(包括 RecurrenceTypePatternStartDatePatternEndDate),使该约会成为在一年中的每天发生的定期系列。

如果使用 GetOccurrence 方法获得定期约会的一个实例,并且该实例的属性发生改变时,将创建 Exception 对象。可以使用 GetRecurrencePattern 方法访问与系列相关的 Exceptions 集合,从而获得约会系列的例外。消息框将显示约会系列的例外的 SubjectOriginalDate 属性,还将显示该例外的当前日期、时间及主题。

有关在 VBScript 中使用本示例的更改说明,请查看示例末尾的“注意”。

Public Sub cmdExample()
    Set myOlApp = New Outlook.Application
    Set myApptItem = myOlApp.CreateItem(olAppointmentItem)   
    myApptItem.Start = #2/2/98 3:00:00 PM#
    myApptItem.End = #2/2/98 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/98 and ends on 2/2/99 
     'and save it.
    Set myRecurrPatt = myApptItem.GetRecurrencePattern
    myRecurrPatt.RecurrenceType = olRecursDaily
    myRecurrPatt.PatternStartDate = #2/2/98#
    myRecurrPatt.PatternEndDate = #2/2/99#
    myApptItem.Save
    
    'Access the items in the Calendar folder to locate
    'the master AppointmentItem for the new series.
    Set myNamespace = myOlApp.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/98.
    myDate = #3/12/98 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/98 3:30:00 PM#
    myOddApptItem.Start = newDate
    myOddApptItem.Save
    
    'Get the recurrence pattern for the master
    'AppointmentItem. Access the collection of
    'exceptions to the regular appointments.
    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

注意  要在 VBScript 中正确地运行本示例,需要在代码中做一些简单的修改。

不必以对象的形式检索应用程序,并且必须使用常量的值,因此:

Set myOlApp = New Outlook.Application
    Set myApptItem = myOlApp.CreateItem(olAppointmentItem)

修改为:

Set myApptItem = Application.CreateItem(1)

并且

myRecurrPatt.RecurrenceType = olRecursDaily

修改为:

myRecurrPatt.RecurrenceType = 0

并且

Set myFolder = myNamespace.GetDefaultFolder(olFolderCalendar)

修改为:

Set myFolder = myNamespace.GetDefaultFolder(9)