I am using Access 97 to transfer records into an excel spreadsheet, I keep getting the follow error :
run-time error '-2147417851 (80010105)'
Method 'CopyFromRecordset' of object 'Range' failed
The code actually does copy the records into excel but then displays the above error in Access. I believe it might have something to do with the fact I was gathering the info for the recordset from different tables, but now I am getting the information from just 1 table and it is still giving me the error. Any ideas on how to solve this
Here is the code i am using :
Private Sub Output_Click()
Dim objXL As Excel.Application
Dim objWkb As Excel.Workbook
Dim objSht As Excel.Worksheet
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set objXL = New Excel.Application
Set rs = db.OpenRecordset("All Records", dbOpenSnapshot)
With objXL
.visible = True
Set objWkb = .Workbooks.Open("C:\My Documents\Report.xls"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Set objSht = objWkb.Worksheets("All Data Input"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
objSht.Range("A2"
.CopyFromRecordset rs
End With
Set objSht = Nothing
Set objWkb = Nothing
Set objXL = Nothing
Set rs = Nothing
Set db = Nothing
End Sub
run-time error '-2147417851 (80010105)'
Method 'CopyFromRecordset' of object 'Range' failed
The code actually does copy the records into excel but then displays the above error in Access. I believe it might have something to do with the fact I was gathering the info for the recordset from different tables, but now I am getting the information from just 1 table and it is still giving me the error. Any ideas on how to solve this
Here is the code i am using :
Private Sub Output_Click()
Dim objXL As Excel.Application
Dim objWkb As Excel.Workbook
Dim objSht As Excel.Worksheet
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set objXL = New Excel.Application
Set rs = db.OpenRecordset("All Records", dbOpenSnapshot)
With objXL
.visible = True
Set objWkb = .Workbooks.Open("C:\My Documents\Report.xls"
Set objSht = objWkb.Worksheets("All Data Input"
objSht.Range("A2"
End With
Set objSht = Nothing
Set objWkb = Nothing
Set objXL = Nothing
Set rs = Nothing
Set db = Nothing
End Sub