using the code below but it doesn't export field names. any ideas how to add them.
Thanks
Thanks
Code:
Dim dbs As DAO.Database
Dim rstGetRecordSet As Recordset
Dim objXL As Object
Dim objCreateWkb As Object
Dim objActiveWkb As Object
Set dbs = CurrentDb
Set objXL = CreateObject("Excel.Application")
Set objCreateWkb = objXL.Workbooks.Add
Set objActiveWkb = objXL.Application.ActiveWorkBook
objXL.Visible = True
objActiveWkb.Sheets.Add
objActiveWkb.Worksheets(1).Name = "Test"
strSQL = "select * from ClientFundSetup"
Set rstGetExportData = dbs.OpenRecordset(strSQL)
With objActiveWkb.Worksheets("Test")
.Cells(1, 1).CopyFromRecordset rstGetExportData
.Columns.AutoFit
End With
Set objActiveWkb = Nothing
Set objCreateWkb = Nothing
Set objXL = Nothing
rstGetExportData.Close
dbs.Close
Set rstGetExportData = Nothing
Set dbs = Nothing