oliv-
Senior Member
- Outlook version
- Outlook 2010 32 bit
- Email Account
- Exchange Server
Hi,
It has been several times that the restrict method returns birthdays, which does not match my filter
What is the reason?
It has been several times that the restrict method returns birthdays, which does not match my filter
What is the reason?
Code:
Option Explicit
Sub ContactDateCheck()
Dim myItems As Outlook.Items
Dim currentAppointment As Object
Dim myAppointments As Object
Dim strDate
Dim strRestriction
Set myItems = Application.GetNamespace("mapi").GetDefaultFolder(olFolderCalendar).Items
strDate = VBA.Format(Date - 1, "Short Date")
strRestriction = "(([Start] >= '" & strDate & " 12:00 am' AND [Start] <= '" & strDate & " 11:59 pm')"
strRestriction = strRestriction & " OR ([End] > '" & strDate & " 12:00 am' AND [End] <= '" & strDate & " 11:59 pm')"
strRestriction = strRestriction & " OR ([Start] < '" & strDate & " 12:00 am' AND [End] > '" & strDate & " 11:59 pm'))"
strRestriction = strRestriction & " AND [Duration] > 0"
If strDate = "" Then strRestriction = "[Start] = 1" 'no result
Set myAppointments = myItems.Restrict(strRestriction)
myAppointments.sort "[Start]"
' myAppointments.IncludeRecurrences = True
MsgBox myAppointments.count
For Each currentAppointment In myAppointments
Dim Datestart As Date
Datestart = strDate
If currentAppointment.Class = olAppointment Then 'And currentAppointment.Start >= Datestart Then
' écrit à partir de E21 verticalement pour les rendez vous successifs
MsgBox currentAppointment.subject & vbCr & currentAppointment.Start & vbCr & currentAppointment.End
End If
Next
End Sub