Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

Thread Tools Rate Thread Display Modes
Old 02-06-2017, 10:09 AM   #1
Newly Registered User
Join Date: Jul 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
dragnor is on a distinguished road
Use MS Access to Extract Outlook Calendar Appointments

Hi Experts,

I'm have run into a wall

I have been given a task on extracting all appointment from a certain number of Shared Calendars in Outlook 2013. I'm able to read the calendar entries but have two major issues.

First issue is that I can't get "Restrict" to work, so every time it is given me all entries

i'm using this code here:

Dim oOutlook As Outlook.Application
Dim oNs As Outlook.namespace
Dim appt As Outlook.AppointmentItem
Dim objOwner As Outlook.recipient
Dim str_sql As String
Dim STR_OWNER As String
Dim item_Start_date As String
Dim item_Start_time As String
Dim app_Start As Date
Dim app_End As Date
Dim FolderCal As Object
Dim i As Long
Dim strRestriction As String
Dim myStart As Date
Dim myEnd As Date
Const olFolderCalendar = 9
myStart = C_DATE
myEnd = C_DATE

strRestriction = "[Start] >= '" & Format(Date, "yyyy/mm/dd") & "' AND [Start] <= '" & Format(Date + 14, "yyyy/mm/dd") & "'"
Set oOutlook = New Outlook.Application
Set oNs = oOutlook.GetNamespace("MAPI")
STR_OWNER = "Thomas"
Set objOwner = oNs.CreateRecipient(STR_OWNER)
If objOwner.Resolved Then
Set FolderCal = oNs.GetSharedDefaultFolder(objOwner, olFolderCalendar)
End If
Set ItemsApt = FolderCal.Items
ItemsApt.IncludeRecurrences = True
ItemsApt.Sort "[Start]"
Set oItemsInDateRange = ItemsApt.Restrict(strRestriction)
oItemsInDateRange.IncludeRecurrences = True
oItemsInDateRange.Sort "[Start]"
For Each appt In oItemsInDateRange

Next issue i'm having is "Recurrences"

The "Only" thing I want, is to take out all Recurrences on the dates they are actually planed in the calender and not only the master appointment start and end date

I have been searching the internet for two weeks now in order to get what I need, but have given up now, and that is why i'm seeking help here.

Many many thanks in advance!!!

dragnor is offline   Reply With Quote
Old 02-08-2017, 11:26 AM   #2
Join Date: May 2004
Location: United States
Posts: 1,385
Thanks: 0
Thanked 48 Times in 43 Posts
ByteMyzer is a jewel in the rough ByteMyzer is a jewel in the rough ByteMyzer is a jewel in the rough ByteMyzer is a jewel in the rough
Re: Use MS Access to Extract Outlook Calendar Appointments

Try changing the following code:
strRestriction = "[Start] >= '" & Format(Date, "mm/dd/yyyy hh:mm AMPM") _
    & "' AND [Start] <= '" & Format(Date + 14, "mm/dd/yyyy hh:mm AMPM") & "'"
ByteMyzer is offline   Reply With Quote

access 2013 , calendar , outlook 2013 , vba

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Sending Outlook Appointments via Access Samantha Modules & VBA 2 08-06-2014 11:35 AM
Calendar with appointments and schedules blogmk Forms 6 07-10-2013 01:26 AM
Looping through outlook appointments in access stephen1990 Modules & VBA 5 10-07-2012 09:33 AM
Schedule Appointments in Outlook using Access? tkepongo General 2 02-06-2012 10:16 AM
Setting Outlook appointments up through Access Aggie05 Modules & VBA 1 02-02-2009 12:02 PM

All times are GMT -8. The time now is 05:15 PM.

Microsoft Access Help
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post

Sponsored Links

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World