Outputting from Access to Outlook Shared Calendar

The following code puts Job details into MY outlook calendar (and obviously into the Calendar of any users who create the record).

What I need is for the Calendar entry to go into my colleague Dan's shared calendar, regardless who creates the entry.

We are using Access 2010, Outlook 2010 and Exchange server 2003.

Hope you can help.

Private Sub Work_Date_AfterUpdate()
    Dim oApp As Object
    Dim oNS As Object
    Dim oCalendar As Object
    Dim ofold As Object
    Set oApp = CreateObject("Outlook.Application")
    Set oNS = oApp.GetNamespace("MAPI")
    Set oCalendar = oNS.GetDefaultFolder(9)
        Set ofold = oCalendar.Items.Add
             With ofold
                    .Subject = Me!engName & " to " & Forms![Job Reports]!Site & " SR " & Forms![Job Reports]![Job Number ID] & " - " & Forms![Job Reports]![Work Request Details]
               .Start = Forms![Job Reports]![Date] 'start date/time of entry
               .Duration = 30
               .ReminderMinutesBeforeStart = 1440 'minutes in a day
    End With
        Set oCalendar = Nothing
    Set oApp = Nothing
End Sub
Who is Participating?
mbizupConnect With a Mentor Commented:
This article shows you how to add an appointment to another user's shared calendar:

I haven't personally verified the code there, but it makes sense to me.  

This is your current code for getting the calendar object:
<<  Set oCalendar = oNS.GetDefaultFolder(9) >>

One of the major differences in the code sample at that site is that it replaces this method of getting your calendar object with this GetSharedDefaultCalendar:
objNS.GetSharedDefaultFolder(objRecip, _

Your existing code uses late binding, which is a better approach in that it will work with any version of office.  The code at this link uses early binding, so you would have to add a reference to MS Outlook for the code to work as-is (and re-check that reference when using different versions of access).  

To change the code to Late Binding, you would have to change your outlook object DIM statements from
Dim objApp As Outlook.Application
Dim objApp As Object

and also change any constants such as olFolderCalendar to their corresponding integers (eg: 9 for olFolderCalendar)
Also, read the comments about that code -- it is dependent on permissions, so it will not work unless you have the proper permissions to write to that other user's calendar.
SparkyPAuthor Commented:
Thank you for coming up with the goods once again.

Had found the code, but the Late Binding tips got it to work.

Have a good weekend.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.