-
Help Using VBA To Get Calendar Item Count
I am trying to count the number of appointments I have in my calendar for the current day.
I have this code:
Dim objOlkApp As Object
Dim olkNS As Outlook.NameSpace
Dim fldrCalendar As Outlook.Folder
Dim fldrMyFolder As Outlook.Folder
Dim olkItems As Outlook.Items
Dim olkFilterItems As Outlook.Items
Dim strFilter As String
Dim dteToday As Date
Dim dteYesterday As Date
dteToday = Date
dteYesterday = Date - 1
Set objOlkApp = CreateObject("Outlook.Application")
Set olkNS = objOlkApp.GetNamespace("MAPI")
Set fldrCalendar = olkNS.GetDefaultFolder(olFolderCalendar)
Set olkItems = fldrCalendar.Items
strFilter = "[Start] <= '" & Format(dteToday & " 11:59pm", "ddddd h:nn AMPM") & _
"' And [End] >= '" & Format(dteYesterday & " 11:59pm", "ddddd h:nn AMPM") & "'"
olkItems.Find (strFilter)
olkItems.Sort "[Start]", False
olkItems.IncludeRecurrences = False
Set olkFilterItems = olkItems.Restrict(strFilter)
This code returns 16 items. I have 3 items on my calendar today. 2 are recurring appointments and 1 is just for today.
If I use an if statement to check if the the [IsRecurring] flag is set and don't include it, I only get 1 item.
How can I get a count for just today that includes only the recurring items listed today, and also get items that are not recurring but in the calendar for today?
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules