DoCmd.TransferSpreadsheet corrupt excel files

Loris 0 Reputation points
2023-06-28T12:29:47.34+00:00

Hi,

I've encountered an issue using TransferSpreadsheet to excel workbook.

I have an Access VBA function that does daily exports, and after adding columns to my Queries all my Excel files are "corrupted".

Repairing works fine (data is ok) but it blocks other scripts that need to open the file automatically. User's image

I investigated inside the XML files to understand what the issue is and found that Access export values where SharedString IDs are expected. Repairing insert my numerical values to sharedstring xml and update the ID (with Excel message: Numerical values stored as text)

User's image

Is there a way to force Access to remove the type (t="s") when exporting to an Excel sheet?

Thanks,

Loris

Microsoft 365 and Office | Access | Development
Microsoft 365 and Office | Access | For business | Windows
{count} votes

1 answer

Sort by: Most helpful
  1. Tanay Prasad 2,250 Reputation points
    2023-06-29T07:18:02.43+00:00

    Hi,

    You can try using the acSpreadsheetTypeExcel12 instead of acSpreadsheetTypeExcel12Xml-

    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, strTable, strPath & strWorkbook
    
    

    Without using the common string table, Access will export the values directly as numeric or text values. This will help to avoid the problem of the "corrupted" material and the requirement for repair.

    There may be an increase in your file size.

    Try this code once and let me know if it works.

    Best Regards.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.