Share via

Exported table as xlsx seems corrupted

Anonymous
2023-03-09T20:45:30+00:00

Can anyone help explain why an excel file would come up with the following error when I run my code to export a table?

This is what the table looks like when I open it. Do you see any issues here?

This is the code I have to do the export.

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "tblETO_Accur_Plnt", filePath & "ETO_ScopeAccur_Plnt.xlsx", True

The hi-lited file is causing the problem. The file below it with the (test) added at the end was created from me opening the same table and doing a manual export.

Just trying to understand how the export from VBA is so different that it causes that error when trying to open the file.

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

  1. Anonymous
    2023-03-10T06:16:43+00:00

    It could be something missing when the excel is exported by code. The file size is difference between the two files. Try acSpreadsheetTypeExcel12Xml

    You can try repair the excel file by File > open > Open and Repair

    Reference:

    Fixed: Excel Cannot Open the File Because of File Format (wondershare.com)

    You can also raise a ticket to Microsoft.

    Please contact your admin/IT department create a support ticket via Microsoft 365 Admin Center> Support> New service request. That support team there will have the correct channel and resources to help you investigate more and find what exactly the reason has caused this situation.

    Best Regards,

    Snow Lu

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2023-03-10T20:43:53+00:00

    The open/repair didn't work, still got the same error, so I will work on creating a ticket.

    I guess I didn't read everything above to start with. I just noticed the note to try the acSpreadsheetTypeExcel12Xml. I did and that worked fine. The file opened with no issues.

    Thank you for your help

    0 comments No comments