Windows 7 Automation issue between access and outlook 2007 on Windows 7 desktop

alorenzini

Senior Member
Joined
Sep 11, 2009
I have a table called form called Appointment Detail which has a Merge to Outlook which is suppose to take the current appointment record and merge into Outlook 2007. The following is the code behind the merge button:

Private Sub cmdMergeToOutlook_Click()
'05/06/08 - To include deletion of same appointments before saving changes to the Calendar
'05/05/09 - Updated to avoid error when Calendar appointments do not have ID numbers included.


On Error GoTo Add_Err

'Save record first to be sure required fields are filled.
'DoCmd.RunCommand acCmdSaveRecord
If Me.Dirty = True Then Me.Dirty = False

'Exit the procedure if appointment has been added to Outlook.
If Me!AddedToOutlook = True Then
MsgBox "This appointment is already added to Microsoft Outlook"
Exit Sub
'Add a new appointment.
Else
Dim objOutlook As New Outlook.Application
Dim objAppts As Outlook.Items
Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Dim objSavedAppt As Object
Dim objAppt As Outlook.AppointmentItem
Dim objRecurPattern As Outlook.RecurrencePattern

'Delete saved appointment
Set objNS = objOutlook.GetNamespace("MAPI")
Set objFolder = objNS.GetDefaultFolder(olFolderCalendar)
Set objAppts = objFolder.Items

For Each objSavedAppt In objAppts
'Added extra check for ":" to avoid Out of Subscript error
If InStr(objSavedAppt.Location, ":") > 0 Then
If Val(Split(objSavedAppt.Location, ":")(0)) = Me!ID Then
objSavedAppt.Delete
End If
End If
Next

'Add new/updated appointment
Set objOutlook = CreateObject("Outlook.Application")
Set objAppt = objOutlook.CreateItem(olAppointmentItem)

With objAppt
.Start = Me!ApptDate & " " & Me!ApptTime
.Duration = Me!ApptLength
.Subject = Me!Appt

If Not IsNull(Me!ApptNotes) Then .Body = Me!ApptNotes
'following code modified by [email protected] to include primary key
'If Not IsNull(Me!ApptLocation) Then .Location = Me!ApptLocation
.Location = Me!ID & ": " & Me!ApptLocation

If Me!ApptReminder Then
.ReminderMinutesBeforeStart = Me!ReminderMinutes
.ReminderSet = True
End If

'Set objRecurPattern = .GetRecurrencePattern

'With objRecurPattern
'.RecurrenceType = olRecursWeekly
'.Interval = 1
'Once per week
'.PatternStartDate = #12/19/2003#
'.PatternStartDate = Me!ApptStartDate
'You could get these values
'from new text boxes on the form.
'.PatternEndDate = #7/23/2003#
'.PatternEndDate = Me!ApptEndDate
'End With

.Save
.Close (olSave)
End With
'Release the AppointmentItem object variable.
Set objAppt = Nothing
Set objOutlook = Nothing
Set objAppts = Nothing
Set objNS = Nothing
Set objFolder = Nothing
Set objSavedAppt = Nothing
End If

'Release the Outlook object variable.
Set objOutlook = Nothing

'Set the AddedToOutlook flag, save the record, display a message.
Me!AddedToOutlook = True
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Appointment Added!"

Exit Sub

Add_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub



End Sub


My issue is when I click the merge button I get the following error:

Error -2147319779 Automation error Library not registered

I check the References and I have the Microsoft Outlook 12.0 Object Library loaded.

AlsoI just tried this on a desktop running XP and it ran fine... Some issue with Windows 7 ?
 
Back
Top Bottom