?
Solved

Export to Excel 2010 from Access 2010 retuns invalid file format

Posted on 2013-12-18
3
Medium Priority
?
1,403 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

771 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