Export to Excel

kadara

Registered User.
Local time
Today, 22:02
Joined
Jun 19, 2010
Messages
43
Hi.
I would like to export a query to Excel.
I put a button on a form with the following command line:

DoCmd.OutputTo acOutputQuery, "Query01", acFormatXLS, "C:\Tmp\Test1.xls", True

When I execute this command, the Excel file is opening with the "File error. Some number formats may have been lost" message (the contents of the excel file is OK, not corrupted).

Please help.
Thanks
 
You could try switching the error warning off prior to running the query and then switch them back on once the query has run.

Code:
DoCmd.SetWarnings False
DoCmd.OutputTo acOutputQuery, "Query01", acFormatXLS, "C:\Tmp\Test1.xls", True
DoCmd.SetWarnings True
 
It's not working. (I've got the same message).
 
Do you still get the error message if you run the code as;
Code:
DoCmd.SetWarnings False
DoCmd.OutputTo acOutputQuery, "Query01", acFormatXLS, "C:\Tmp\Test1.xls", [B][COLOR="Magenta"]False[/COLOR][/B]
DoCmd.SetWarnings True
 
The same problem...
Anytime, when I open the Excel file, appear the error message.
 
So are you saying that if you run the variation on the code I posted in my previous post that the message is suppressed until you physically open the Excel file or that you get the message any way :confused:
 
I get the message in that case when I physically open the Excel file.
 
I get the message in that case when I physically open the Excel file.

OK, so that means the error message is originating from Excel. Which is why the DoCmd.SetWarnings command had no effect.

So it would seem that one of the number formats that you are using in Access is not compatible/supported in Excel.
 

Users who are viewing this thread

Back
Top Bottom