newbie46
asked on
Retrieving Recurring Items from Outlook Calendar using VBA
I am using the following code to retrieve Outlook calendar items and store them into an Access 2007 table. This code works correctly for non-Recurring Items.
Private Sub RetrieveOutlookEntries_Cli ck()
Dim OutObj As Outlook.Application
Dim OutAppt As Outlook.AppointmentItem
Dim OutItems As Outlook.Items
Dim ItemFilter As Variant
Set OutObj = CreateObject("Outlook.Appl ication")
Set objNS = OutObj.GetNamespace("MAPI" )
Set objFolder = objNS.GetDefaultFolder(olF olderCalen dar)
Set OutItems = objFolder.Items
OutItems.Sort "[Start]"
For Each OutAppt In OutItems
If OutAppt.Start >= "1/1/2013" And OutAppt.Start <= "1/25/2013" Then
db.execute "INSERT INTO TempOutlookEntries ( ) VALUES ()
End If
Next
Set OutAppt = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set OutObj = Nothing
End Sub
1) Are the following statements causing the Recurring Items to not be included?
Dim OutAppt As Outlook.AppointmentItem
Dim OutItems As Outlook.Items
2) Does additional code need to be added to process the Recurring Items?
Thanks.
Private Sub RetrieveOutlookEntries_Cli
Dim OutObj As Outlook.Application
Dim OutAppt As Outlook.AppointmentItem
Dim OutItems As Outlook.Items
Dim ItemFilter As Variant
Set OutObj = CreateObject("Outlook.Appl
Set objNS = OutObj.GetNamespace("MAPI"
Set objFolder = objNS.GetDefaultFolder(olF
Set OutItems = objFolder.Items
OutItems.Sort "[Start]"
For Each OutAppt In OutItems
If OutAppt.Start >= "1/1/2013" And OutAppt.Start <= "1/25/2013" Then
db.execute "INSERT INTO TempOutlookEntries ( ) VALUES ()
End If
Next
Set OutAppt = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set OutObj = Nothing
End Sub
1) Are the following statements causing the Recurring Items to not be included?
Dim OutAppt As Outlook.AppointmentItem
Dim OutItems As Outlook.Items
2) Does additional code need to be added to process the Recurring Items?
Thanks.
ASKER
capricorn1,
With that added statement, the code continuously loops through:
For Each OutAppt In OutItems
If OutAppt.Start >= "1/1/2013" And OutAppt.Start <= "1/25/2013" Then
db.execute "INSERT INTO TempOutlookEntries ( ) VALUES ()
End If
When I break to stop the code from executing, click Debug and then hit F8, it is still cycling through the If - End If.
The execution never ends. Is there a way to limit the OutItems that it is processing?
With that added statement, the code continuously loops through:
For Each OutAppt In OutItems
If OutAppt.Start >= "1/1/2013" And OutAppt.Start <= "1/25/2013" Then
db.execute "INSERT INTO TempOutlookEntries ( ) VALUES ()
End If
When I break to stop the code from executing, click Debug and then hit F8, it is still cycling through the If - End If.
The execution never ends. Is there a way to limit the OutItems that it is processing?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you, capricorn1. That worked!!
outItems.IncludeRecurrence
OutItems.Sort "[Start]"