访问 Excel 导出错误

Access to Excel Export Error

我有一个 DoCmd 可以将查询导出到 Excel 文件,但是当我打开 Excel 文件时,我收到一条错误消息,指出 "Excel cannot open because the file format and extension is not valid."当我导出文件并尝试打开它时,是什么导致发生这种情况?

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryComplete", "C:\Users\Downloads\Reports\Report_Name " & Format(Date, "mmddyy") & ".xlsx", True

如果您想要 acSpreadsheetTypeExcel9 作为 SpreadsheetType 选项,请使用 .xls 作为文件扩展名。

如果您想要 .xlsx 作为文件扩展名,请使用 acSpreadsheetTypeExcel12Xml 作为 SpreadsheetType

错误发生是因为 acSpreadsheetTypeExcel9.xlsx 不是有效组合。