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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.