VBA Access - Create Excel Active X Object Error
I am facing a strange situation with my MS Access VBA Code. I have a form
with several buttons for importing data into tables coming from different
Excel files.
In the form, 2 buttons have to open the same Excel workbook but different
sheets. In order to do this, I called the following subroutine in one of
the buttons:
Sub solar_solar(showNotification As Boolean)
Dim xlApp As Excel.Application
Dim eexWB As Workbook
Dim updatedDates As String
Dim insertedDates As String
On Error GoTo errorHandling
' open excel application and source file
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = False
xlApp.DisplayAlerts = False
Set eexWB = xlApp.Workbooks.Open(c_sourceFile_solar, False, True)
' update records
updatedDates = updateWindOrSolarRecords(eexWB, cWindSheet,
cStartRowWind, cStartColWind, c_sql_WindTable)
' more code ...
End Sub
The other subroutine (wind_wind) has exactly the same code for opening the
excel file. The solar_solar subroutine runs just fine but when then I try
to run the second one, the code does not start executing and I get the
alert: "Object library feature not supported" (Fehler beim Kompilieren:
Funktionsmerkmal der Objektbibliothek nicht unerstützt) and points to the
line:
Set xlApp = CreateObject("Excel.Application")
This occurs in Windows 7 MS Access 2002. I do not understand how it is
possible for this code to run well in one subroutine and not in another,
when it is practically the same. Has anyone experienced something similar?
Any advice?
Thanks.
No comments:
Post a Comment