I am exporting a query to Excel in Access 2013. This is the syntax that I am using for the export
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "qryDataExport", strExportPath, True
The data transfers as it should, but one of the fields in the query is titled Player #
and when exported to Excel this becomes Player .
How can I keep the #
intact with the export?
You can use the following function to export stuff to an .xlsx file, without having to deal with the limitations of
DoCmd.TransferSpreadsheet
Call it:
CustomExcelExport "qryDataExport", strExportPath
While issue is reproducible with
DoCmd.TransferSpreadsheet
, consider DoCmd.OutputTo which retains formatting of query. The former method may focus more on spreadseet formatting.And in fact,
DoCmd.OutputTo
looks to be the automated version of the External Data \ Excel Export ribbon method (selecting to keep all formatting):