Outlook VBA教程:AppointmentItem属性

返回为例外的AppointmentItem对象。对于已删除的约会无效。

expression.AppointmentItem

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

VBA示例

本 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/1998 3:00:00 PM#
    myApptItem.End = #2/2/1998 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/1998#
    myRecurrPatt.PatternEndDate = #2/2/1999#
    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/1998 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/1998 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)

上页:Outlook VBA教程:Application属性 下页:Outlook VBA教程:Assistant属性

Outlook VBA教程:AppointmentItem属性:相关链接

Outlook VBA教程:Assistant属性 Outlook VBA教程:AssistantName属性
Outlook VBA教程:AssistantTelephoneNumber属性 Outlook VBA教程:Attachments属性
Outlook VBA教程:AutoForwarded属性 Outlook VBA教程:AutoResponse属性
Outlook VBA教程:BCC属性 Outlook VBA教程:BillingInformation属性
Outlook VBA教程:Birthday属性 Outlook VBA教程:Body属性
Outlook VBA教程:BodyFormat属性 Outlook VBA教程:Business2TelephoneNumber属性
Outlook VBA教程:BusinessAddress属性 Outlook VBA教程:BusinessAddressCity属性
Outlook VBA教程:BusinessAddressCountry属性 Outlook VBA教程:BusinessAddressPostalCode属性
Outlook VBA教程:BusinessAddressPostOfficeBox属性 Outlook VBA教程:BusinessAddressState属性
Outlook VBA教程:BusinessAddressStreet属性 Outlook VBA教程:BusinessFaxNumber属性
版权所有 © 中山市飞娥软件工作室 证书:粤ICP备09170368号