Automation issue between access and outlook 2007

alorenzini

Registered User.
Local time
Today, 10:18
Joined
Oct 16, 2007
Messages
25
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()
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 theDBguy@gmail.com 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 Outlokk 12.0 Object Library loaded.

I am running Windows 7 is that a problem?
I also just trying to run the same database on a desktop that has XP Pro on it and it worked fine.
 
I don't have windows 7 and I have not written much for Outlook 2007.

But you might try a couple of things


  1. try late binding
  2. createobject("outlook.application.12") - ie refer to the version
let me know how it goes.
 

Users who are viewing this thread

Back
Top Bottom