Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / November 2006

Tip: Looking for answers? Try searching our database.

Counting days

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
i.mangelsdorf@acslabs.com.au - 18 Nov 2006 05:46 GMT
Hi there

Is it possible to count the number of days a certain label type occurs
in a calendar?

Regards

Ian
Ken Slovak - [MVP - Outlook] - 19 Nov 2006 19:02 GMT
Yes. Use an AdvancedSearch to do that. It's the easiest way.

Set up the search criteria by opening a dialog for a custom calendar view.
Click Filter and go to the Advanced tab. Use the All Appointments setting to
add Label = whatever as a filter. Go to the SQL tab and check the box to use
only that. Copy the SQL criteria and that's your AdvancedSearch filter. Make
the search folder the calendar folder name and get the Count of the returned
Results collection.

An alternative would be to use the filter as a Restrict filter on the Items
collection of the folder using the "@SQL="filter undocumented syntax. Get
the Count of the returned Items collection.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> Hi there
>
[quoted text clipped - 4 lines]
>
> Ian
i.mangelsdorf@acslabs.com.au - 21 Nov 2006 07:27 GMT
Thanks for the Help Ken

I have a run into a couple of problems trying this.  I am using

Sub SearchCalendar()

Dim objSch As Outlook.Search
   Dim rsts As Outlook.Results
   Dim i As Integer
   blnSearchComp = False
   Const strF1 As String = "urn:schemas:calendar:location = 'Kish
Island'"

   Const strS1 As String = "IJM Travel Calendar"
   Set objSch = Application.AdvancedSearch(Scope:=strS1,
Filter:=strF1, SearchSubFolders:=False, Tag:="SubjectSearch")
   While blnSearchComp = False
       DoEvents
   Wend
   Set rsts = objSch.Results

       MsgBox rsts.Count

End Sub
(straight out of the Online Help)

I end up with an error in the set objSch line which I assume is the way
the strF1 string has been set,  is there anything there that ive messed
up???

secondly , I can this will work fine for counting the number of events
that meet the search but where I have events running multiple days will
it not just report this as 1 event not duration??

Once again your help is appreciated

Cheers

Ian
Ken Slovak - [MVP - Outlook] - 21 Nov 2006 15:09 GMT
If you have spaces in your search scope you need to enclose the string in
single quotes:

Const strS1 As String = "'IJM Travel Calendar'"

The same would apply for the filter string.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> Thanks for the Help Ken
>
[quoted text clipped - 35 lines]
>
> Ian
i.mangelsdorf@acslabs.com.au - 21 Nov 2006 07:27 GMT
Thanks for the Help Ken

I have a run into a couple of problems trying this.  I am using

Sub SearchCalendar()

Dim objSch As Outlook.Search
   Dim rsts As Outlook.Results
   Dim i As Integer
   blnSearchComp = False
   Const strF1 As String = "urn:schemas:calendar:location = 'Kish
Island'"

   Const strS1 As String = "IJM Travel Calendar"
   Set objSch = Application.AdvancedSearch(Scope:=strS1,
Filter:=strF1, SearchSubFolders:=False, Tag:="SubjectSearch")
   While blnSearchComp = False
       DoEvents
   Wend
   Set rsts = objSch.Results

       MsgBox rsts.Count

End Sub
(straight out of the Online Help)

I end up with an error in the set objSch line which I assume is the way
the strF1 string has been set,  is there anything there that ive messed
up???

secondly , I can see this will work fine for counting the number of
events that meet the search but where I have events running multiple
days will it not just report this as 1 event not duration??

Once again your help is appreciated

Cheers

Ian
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.