I am trying to copy an access recordset using a macro in excel. This works on some machines and on others it gives a runtime error. We thought the problem was an Office 2K compatability issue, but we recently ran across an Office 97 machine that has the same issue.
Here is the code:
Sub CopyRecordset()
Dim Db1 As Database
Dim Rs1 As Recordset
Worksheets("CalData"
.Select
Range("A2:E1000"
.Select
Selection.ClearContents
Range("A2"
.Select
Set Db1 = DBEngine.OpenDatabase("C:\Salaried Calendar\Salaried Vacation-Branch - 97.mdb"
Set Rs1 = Db1.OpenRecordset(Name:="VacQuery", Type:=dbOpenDynaset)
With Worksheets("CalData"
.Range("A2"
.CopyFromRecordset Rs1
End With
Db1.Close
End Sub
The error occurs at Set Db1= DBEngine... saying it can't find the database (it is definitely there and spelled correctly). If we change the: "Dim Db1 as Database" to Databases it finds the database but gives a compile error "Method or data member not found" at OpenRecordset.
I can run this code on my Office 97 machine perfectly, but it does not run on my Office 2000 machine (nor anyone else's we've found).
Is there a different/easier way to accomplish copying this recordset from a closed access database into an excel spreadsheet?
Here is the code:
Sub CopyRecordset()
Dim Db1 As Database
Dim Rs1 As Recordset
Worksheets("CalData"
Range("A2:E1000"
Selection.ClearContents
Range("A2"
Set Db1 = DBEngine.OpenDatabase("C:\Salaried Calendar\Salaried Vacation-Branch - 97.mdb"
Set Rs1 = Db1.OpenRecordset(Name:="VacQuery", Type:=dbOpenDynaset)
With Worksheets("CalData"
.CopyFromRecordset Rs1
End With
Db1.Close
End Sub
The error occurs at Set Db1= DBEngine... saying it can't find the database (it is definitely there and spelled correctly). If we change the: "Dim Db1 as Database" to Databases it finds the database but gives a compile error "Method or data member not found" at OpenRecordset.
I can run this code on my Office 97 machine perfectly, but it does not run on my Office 2000 machine (nor anyone else's we've found).
Is there a different/easier way to accomplish copying this recordset from a closed access database into an excel spreadsheet?