A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Counting Appointments



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 17th 09, 08:35 AM posted to microsoft.public.outlook.program_vba
baggers
external usenet poster
 
Posts: 5
Default Counting Appointments

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
  #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



  #3  
Old July 17th 09, 04:32 PM posted to microsoft.public.outlook.program_vba
baggers
external usenet poster
 
Posts: 5
Default Counting Appointments

Sue
Thanks for that answer, it explains why I was getting strange numbers.

The method you suggest is terribly slow (we have multiple calendars in which
there are recurring appointments with no end date).
Do you know of a quicker way to get the number of appointments between two
specific dates?

Thanks
Simon.

"Sue Mosher [MVP]" wrote:

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




 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
counting appointments baggers Outlook - Calandaring 1 July 16th 09 06:43 PM
Counting reocurrances Grandad Outlook - General Queries 1 January 11th 08 12:48 PM
Counting days [email protected] Outlook and VBA 4 November 21st 06 03:09 PM
Counting Attachments in Messages Chris Rhodes Outlook and VBA 5 June 21st 06 04:57 PM
outlook is miss counting contacts, why Rosalind Outlook - Calandaring 0 April 13th 06 07:12 PM


All times are GMT +1. The time now is 07:02 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.