I am ususing this code to send an Access report to Excel. It works, however it does not include column headings. Is it possible to include these? Thanks
Code:
Dim stDocName As String
Dim stFileName As String
stDocName = "Queryform2"
stFileName = "C:\" & stDocName & ".xls"
DoCmd.OutputTo acOutputReport, "QueryForm2", acFormatXLS, stFileName, True, "", , acExportQualityPrint
Exporting Column titles to Excel
-
- Administrator
- Posts: 78535
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Exporting Column titles to Excel
Exporting a report to Excel leaves much to be desired. Subtotals, for examples, are omitted.
If possible, try to export a table or query using DoCmd.TransferSpreadsheet. You can specify whether you want to export as Excel 97-2003 workbook (*.xls) or as Excel 2007-2010 workbook (*.xlsx), and whether you want to include field names or not.
If possible, try to export a table or query using DoCmd.TransferSpreadsheet. You can specify whether you want to export as Excel 97-2003 workbook (*.xls) or as Excel 2007-2010 workbook (*.xlsx), and whether you want to include field names or not.
Best wishes,
Hans
Hans
-
- StarLounger
- Posts: 56
- Joined: 24 Jan 2012, 21:48
Re: Exporting Column titles to Excel
Thankyou Hans. I will read up on TransferSpreadsheet to see what I can do. I realised after asking the question, the headings in the Access report are all put in manually, they do not pass to the Access report as data. Never mind, I now have a starting point from you. Thanks again