Solved

Export to Excel 2010 from Access 2010 retuns invalid file format

Posted on 2013-12-18
3
1,314 Views
Last Modified: 2015-09-14
I have  table that I want to export, simple, but when I use the below incode, it creates the workbook, but when I try to open the file, I get a the error message that the file format or file extension is not valid.

            DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, _
            "tblExcelExportData", "C:\TEMP" & "\TestDataExport.xlsx", True

Not sure what to do as it looks fine to me

Sandra
0
Comment
Question by:ssmith94015
3 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 39727631
use this

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12xml, _
            "tblExcelExportData", "C:\TEMP" & "\TestDataExport.xlsx", True


or


DoCmd.TransferSpreadsheet acExport, 10, _
            "tblExcelExportData", "C:\TEMP" & "\TestDataExport.xlsx", True
0
 

Author Closing Comment

by:ssmith94015
ID: 39727639
First version worked, thank you.
Sandra
0
 

Expert Comment

by:Bdecker9
ID: 40977165
This is a late addendum to the issue, but you'll also sometimes get that error if you try to export to an Excel file that already exists, because Access will try to append a new worksheet tab into an existing .xlsx file. If the .xlsx file was in an earlier version of Excel, for example, then the resulting .xlsx will throw that error.

We usually add code to ensure the .xlsx is a new file, or delete it if it already exists before continuing the export.

Like:  
If(Len(Dir(filename))>0 Then Kill filename
Docmd.TransferSpreadsheet acExport,,filename,queryname

Open in new window

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question