I am exporting the contents of an Access table into an existing excel spreadsheet but I then
tried this with a non-existing spreadsheet and it did not create the spreadsheet.
What am I missing in order to create a new spreadsheet and export the contents of an Access table into that new excel spreadsheet?
thanks
I am using the following code to export to an existing spreadsheet but it will not create a new spreadsheet:
tried this with a non-existing spreadsheet and it did not create the spreadsheet.
What am I missing in order to create a new spreadsheet and export the contents of an Access table into that new excel spreadsheet?
thanks
I am using the following code to export to an existing spreadsheet but it will not create a new spreadsheet:
Code:
Dim LineNum As Integer
Dim db As DAO.Database
Dim rs1 As DAO.Recordset
Dim objXL As Object
Dim objWkb As Object
Dim objSht As Object
Set objXL = CreateObject("Excel.Application")
Set db = CurrentDb
Set rs1 = db.OpenRecordset("NW_Excel_tbl", dbOpenSnapshot)
With objXL
.Visible = True
Set objWkb = .Workbooks.Open("C:\Stuff\my.xlsx")
Set objSht = objWkb.Worksheets("works") 'RSP
objWkb.Worksheets("RSP").Activate
With objSht
.Range("A" & lngLastRow).CopyFromRecordset rs1
End With
Set rs1 = Nothing
Set objSht = Nothing