使用VBA,我需要在Outlook中显示每个定期约会的INSTANCE的开始日期。
问题是,当我使用appt.start时,它会显示SERIES的开始日期,这没有用!!
示例:定期约会发生在2009年的每个月的第一天。 我想显示12个INSTANCES,有12个不同的开始日期(1/1/09,2/1/09等)。 换句话说,所有12个都不应该显示开始日期= 1/1/09。
由于
答案 0 :(得分:1)
日期限制将获取在指定日期之间发生的定期约会的实例但是当您询问实例的属性时 - 例如.IsRecurring
或.AllDayEvent
,Outlook会将指针重定向到第一次定期预约(父母原样)。解决这个问题的方法是在检查其他属性之前检查开始和结束日期(复制到局部变量)。
Dim olNS As Outlook.Namespace
Dim olRec As Outlook.Recipient
Dim myCalItems As Outlook.Items
Dim strRestriction As String
Dim ItemstoCheck As Outlook.Items
Dim MyItem As Outlook.AppointmentItem
Dim datAppStart As Date
Dim datAppEnd As Date
Set myCalItems = olNS.GetSharedDefaultFolder(olRec, olFolderCalendar).Items
' Including recurrent appointments requires sorting by the Start property, apparently!
myCalItems.Sort "[Start]", False
myCalItems.IncludeRecurrences = True
strRestriction = "[Start]<= " & Quote(datEndDate & " 12:00 AM") & " AND [End] >= " & _
Quote(datStartDate & " 11:59 PM")
Set ItemstoCheck = myCalItems.Restrict(strRestriction)
For Each MyItem In ItemstoCheck
If MyItem.Class = olAppointment Then
'Save Start and end dates in case replaced by first instance of recurring appointment
datAppStart = MyItem.Start
datAppEnd = MyItem.End
等