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

alorenzini

Senior Member
Joined
Sep 11, 2009
Messages
12
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 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 Outlook 12.0 Object Library loaded.

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

Solution
The error you're encountering, "Error -2147319779 Automation error Library not registered," typically indicates a problem accessing or utilizing the Outlook library in your VBA code. This can happen when there are issues with the registration or compatibility of the required libraries. Here are some steps to troubleshoot and potentially resolve this issue:

Potential Solutions:​

  1. Check Outlook Version:
    • Ensure that the version of Outlook installed on the Windows 7 machine matches the version referenced in your VBA code (Outlook 2007 in this case).
    []Check References:
    • Double-check the References in the VBA editor to ensure that the Microsoft Outlook xx.x Object Library reference is correct...
The error you're encountering, "Error -2147319779 Automation error Library not registered," typically indicates a problem accessing or utilizing the Outlook library in your VBA code. This can happen when there are issues with the registration or compatibility of the required libraries. Here are some steps to troubleshoot and potentially resolve this issue:

Potential Solutions:​

  1. Check Outlook Version:
    • Ensure that the version of Outlook installed on the Windows 7 machine matches the version referenced in your VBA code (Outlook 2007 in this case).
    []Check References:
    • Double-check the References in the VBA editor to ensure that the Microsoft Outlook xx.x Object Library reference is correct, specifically targeting the Outlook version you are using.
    [
    ]Re-Register Library:
    • You can try re-registering the Outlook library:
      • Open Command Prompt as an administrator.
      • Enter the command: regsvr32 "path to Outlook DLL file", where the path should point to the Outlook library file.
    []Run as Administrator:
    • Try running Access with elevated privileges to see if it resolves the issue.
    [
    ]Office Repair:
    • Perform a repair of the Microsoft Office installation on the Windows 7 machine. This might help in re-establishing the necessary library registrations.
    []Compatibility Mode:
    • Try running Access in compatibility mode for Windows XP to see if it resolves the issue.
    [
    ]64-bit vs. 32-bit:
    • If you're using a 64-bit version of Office, there might be compatibility issues. Try running the 32-bit version to see if it resolves the problem.

      Additional Notes:​

      • It's interesting that the code runs fine on a Windows XP machine but encounters issues on a Windows 7 system. This could be related to system-specific configurations or libraries.
      • Check for any Windows 7 specific configurations that might affect how the Outlook library is registered or accessed.
      By following these steps and ensuring compatibility between the Outlook version, references in your VBA code, and the Windows system, you should be able to troubleshoot and resolve the "Library not registered" error you're facing.
 

Solution
Back
Top