DoCmd.TransferSpreadsheet Error Access 2010
Posted on 2014-02-04
I am getting an error when I open an Excel spreadsheet that was created by my Access 2010 application. The error is:
"Excel found unreadable content in tablename.xlsx'. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click Yes."
When I click Yes, the spreadsheet opens and has all the data that I sent. I have to do a "Save As" to save this repair.
I am using Access 2010 VBA's DoCmd.TransferSpreadsheet command to export data from a temp table that I created.
Other functions within this same application can create Excel files using the same DoCmd function without encountering this error. In this case I am creating a temporary table with the name that I want the Excel "tab" to have. The other examples use a query or a Table as the source of the data.
Example of the code:
DoCmd.TransferSpreadsheet acExport, , strTempTableName, pstrExcelFileSpec
strTempFileName = "C01A_Pool_203"
pstrExcelFileSpec = "O:\Home\YieldTable_2013_12.xlsx"