View Single Post
  #2  
Old July 17th 09, 12:21 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default Counting Appointments

That's a known side effect of using IncludeRecurrences: Count isn't
meaningful. To get an accurate count, you can loop through the filtered
Items collection in a For Each ... Next loop and increment a counter
variable on each pass.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"baggers" wrote in message
...
Hi Guys
I'm trying to count the number of appointments in a calendar using the
restrict method.
If I add "items.IncludeRecurrences = True" then the numbers returned all
equal 2147483647.

Here is a code snippet:
dateFrom = Date.Today
dateTo = CDate("2014-01-01")
strFind = "[Start] = " & DoubleQuote(Format(dateFrom, "dd MMM yyyy")) & "
AND [Start] " & DoubleQuote(Format(dateTo, "dd MMM yyyy"))
items = mapi.GetFolderFromID(sID).Items
items.Sort("[Start]")
items.IncludeRecurrences = True
restrictedItems = items.Restrict(strFind)
itemCounter = itemCounter + restrictedItems.Count

can anyone see where the problem lies?

Thanks



Ads