Solved

Export from Access 2007 table to Excel 2007 triggers "External table is not in the expected format"

Posted on 2014-02-06
5
579 Views
Last Modified: 2014-02-18
Hi

I have an Access 2007 app that runs automatically on a server and generates a number of reports based on data in an Access database. One of these reports is actually a simple export of one table with currently just under 17,000 rows and about 65 columns to an Excel 2007 (SP3) xlsx spreadsheet wich is generated in the process (i.e. it does not exist before the export).

Since a while, I get errors from time to time on that process. I am using DoCmd.TransferSpreadsheet, and after the first errors I changed the Excel type to acSpreadsheetTypeExcel12Xml, because other types gave me an error. For a while that worked well, but now, 2 days in a row, I got the "External table is not in the expected format" error. I am a bit puzzled as to what I should do. My export statement is:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "myTable", sOutputFileName

Even stranger is that, when in both error cases I ran the app again with breakpoints and executed the same statement by stepping it in Debug mode, it worked fine !

As I have read over the internet that some people say that there is a size limit to what can be imported in Excel with the current method, I'm a bit nervous, because the source table grows in number of rows every day, albeit very slowly.

Can you tell me:
- what could be wrong ?
- what can I do ?

Thanks
Bernard
0
Comment
Question by:bthouin
  • 3
  • 2
5 Comments
 
LVL 84
ID: 39838968
Is anything happening before you run that TransferSpreadsheet call?

Anytime I see code that mysteriously breaks, but then runs fine when I'm in Break mode I think of timing issues. For example, if Excel is busy doing something else, then you might run into conflicts with that.
0
 
LVL 1

Author Comment

by:bthouin
ID: 39841202
No, nothing is happening with Excel before. This is the first Excel produced each morning. But I thought about something else: although the DoCdm fails, an empty Excel is created. So when I re-run the DoCmd, the Excel with the proper name is already there, it's then just filled with data. And I have read MANY posts in various forums from people having similar troubles that it very often works when the Excel file already exists !

So, should I create the spreadsheet first and then fill it ? Although it should not be needed, if it works, it's good enough for me.

What do you think ?
0
 
LVL 84
ID: 39841422
Yes, I'd go along with that.
0
 
LVL 1

Accepted Solution

by:
bthouin earned 0 total points
ID: 39856122
Actually, I did something meaner: I repeated the Docmd call a second time if the first one threw an error, which it always does. But because Excel is already runing and the file has been created when the second call is issued, that second call succeeds...:-)

So, problem solved (albeit inelegantly).

Bernard
0
 
LVL 1

Author Closing Comment

by:bthouin
ID: 39866883
My own solution, and not very handsome at that...
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
A Table within a User Form 24 42
Records from Access to Excel to specific cells 5 24
Run Stored Procedure uisng ADO 5 20
Excel VBA 30 38
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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