Ограничение по дате выберет экземпляры повторяющейся встречи, которые происходят между датами, указанными НО при опросе свойств экземпляра - например, .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
и т.д.