Dim
myStart
As
Date
Dim
myEnd
As
Date
Dim
oCalendar
As
Outlook.folder
Dim
oItems
As
Outlook.items
Dim
oItemsInDateRange
As
Outlook.items
Dim
oFinalItems
As
Outlook.items
Dim
oAppt
As
Outlook.AppointmentItem
Dim
strRestriction
As
String
myStart =
Date
myEnd = DateAdd(
"d"
, 30, myStart)
Debug.Print
"Start:"
, myStart
Debug.Print
"End:"
, myEnd
strRestriction =
"[Start] >= '"
& _
Format$(myStart,
"mm/dd/yyyy hh:mm AMPM"
) _
&
"' AND [End] <= '"
& _
Format$(myEnd,
"mm/dd/yyyy hh:mm AMPM"
) &
"'"
Debug.Print strRestriction
Set
oCalendar = Application.session.GetDefaultFolder(olFolderCalendar)
Set
oItems = oCalendar.items
oItems.IncludeRecurrences =
True
oItems.Sort
"[Start]"
Set
oItemsInDateRange = oItems.Restrict(strRestriction)
strRestriction =
"@SQL="
& Chr(34) & PropTag _
&
"0x0037001E"
& Chr(34) &
" like '%team%'"
Set
oFinalItems = oItemsInDateRange.Restrict(strRestriction)
oFinalItems.Sort
"[Start]"
For
Each
oAppt
In
oFinalItems
Debug.Print oAppt.Start, oAppt.Subject
Next
End
Sub