VBAinspire
Programmer
I am trying to use the CopyFromRecordset action to transfer an Access recordset to Excel. It works on some machines but not on others. On some machines, the code crashes with the following error:
Run-time Error 430: Class does not support Automation or does not support expected interface.
This is the test funtion I wrote to test the CopyFromRecordset action (xlBook and xlApp declared in main function):
Private Function RunTest5() As Boolean
'Test 5 - Copy Recordset/Close Excel
On Error GoTo Crash
Dim rstTest As ADODB.Recordset
Set rstTest = New ADODB.Recordset
rstTest.Open ("Select * from HELP", _
CurrentProject.Connection, adOpenStatic, adLockReadOnly
xlBook.Worksheets(1).Range("A1" = "Recordset Test to Excel"
xlBook.Worksheets(1).Range("A3".CopyFromRecordset rstTest
rstTest.Close
xlBook.Close False
xlApp.Quit
RunTest5 = True
Exit Function
Crash:
RunTest5 = False
MsgBox "Test 5 Error: " & Err.Number & " - " & Err.Description
End Function
Any ideas on what could be causing the problem and how to fix it?
Run-time Error 430: Class does not support Automation or does not support expected interface.
This is the test funtion I wrote to test the CopyFromRecordset action (xlBook and xlApp declared in main function):
Private Function RunTest5() As Boolean
'Test 5 - Copy Recordset/Close Excel
On Error GoTo Crash
Dim rstTest As ADODB.Recordset
Set rstTest = New ADODB.Recordset
rstTest.Open ("Select * from HELP", _
CurrentProject.Connection, adOpenStatic, adLockReadOnly
xlBook.Worksheets(1).Range("A1" = "Recordset Test to Excel"
xlBook.Worksheets(1).Range("A3".CopyFromRecordset rstTest
rstTest.Close
xlBook.Close False
xlApp.Quit
RunTest5 = True
Exit Function
Crash:
RunTest5 = False
MsgBox "Test 5 Error: " & Err.Number & " - " & Err.Description
End Function
Any ideas on what could be causing the problem and how to fix it?