1

Topic: Export in Excel. The valid file format differs from specified by its extension.

All hello.
Who in course, prompt please.
Access 2003. I create  a file object, I write to it, I close.
And at discovery there is a warning that the valid file format differs from file name specified by its extension.
What it for a hogwash and how with it to struggle?

Dim xlApp As Object ' Excel. Application
Dim xlBook As Object ' Excel. Workbook
Dim xlSheet As Object ' Excel. Worksheet
dim filename as string
filename = "the H: \catalogue \" both "" and ".xls"
Set xlApp = CreateObject ("Excel. Application")
Set xlBook = xlApp. Workbooks. Add
Set xlSheet = xlApp. ActiveSheet
'-------------------------------------------------------------------------------------
....
'-------------------------------------------------------------------------------------
xlBook. SaveAs filename
xlBook. Close
xlApp. Quit
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing

2

Re: Export in Excel. The valid file format differs from specified by its extension.

And an ex-fur-tree from what office? If 2007 also is higher most easier to give to a file correct xlsx extension at once.
If it is necessary nevertheless xls, it is necessary to save not in a format by default, and in a format 97-2003

3

Re: Export in Excel. The valid file format differs from specified by its extension.

Here at a forum someone wrote that by default the file forms in format Excel 5.0
And why you should create a file, instead of to use export? For example

Select Case sngVersion
stDocName = "qSpr_"
Select Case sngVersion
Case Is <12
DoCmd. OutputTo acOutputQuery, stDocName, "MicrosoftExcelBiff8 (*.xls)", "log .xls", True
Case Else
DoCmd. OutputTo acOutputQuery, stDocName, "ExcelWorkbook (*.xlsx)", "log .xlsx", True
End Select

4

Re: Export in Excel. The valid file format differs from specified by its extension.

The first line in the code is not necessary. Copied by mistake.

5

Re: Export in Excel. The valid file format differs from specified by its extension.

Joss wrote:

why you should create a file, instead of to use export?

Or it is even better - to make an empty file with all necessary formatting/macroes/formulas, etc., and in the program to open for an insertion of the data a copy of this file. For an insertion of data CopyFromRecordset works very quickly, it is possible to do additional changes, to work with several tabs without manual creation of the static data and formatting. Reports or entry form turn out rather professionally .

6

Re: Export in Excel. The valid file format differs from specified by its extension.

To method xlBook. SaveAs it is possible to specify specific file type.
Interesting, and what file type at you turns out? On Excel 5.0 it so did not swear.

7

Re: Export in Excel. The valid file format differs from specified by its extension.

MrShin wrote:

it is passed...
Or it is even better - to make an empty file with all necessary formatting/macroes/formulas, etc., and in the program to open for an insertion of the data a copy of this file. For an insertion of data CopyFromRecordset works very quickly, it is possible to do additional changes, to work with several tabs without manual creation of the static data and formatting. Reports or entry form turn out rather professionally .

At me by the way and it is made. The heap of templates on many cases of life is created. Beforehand all necessary cells are formatted. And are then preempted  in proper places. Conveniently enough.

8

Re: Export in Excel. The valid file format differs from specified by its extension.

MrShin wrote:

And an ex-fur-tree from what office? If 2007 also is higher most easier to give to a file correct xlsx extension at once.
If it is necessary nevertheless xls, it is necessary to save not in a format by default, and in a format 97-2003

MrShin, thanks, changed the extension on xlsx and ceased to swear.

Joss wrote:

And why you should create a file instead of to use export? For example

Select Case sngVersion
stDocName = "qSpr_"
Select Case sngVersion
Case Is <12
DoCmd. OutputTo acOutputQuery, stDocName, "MicrosoftExcelBiff8 (*.xls)", "log .xls", True
Case Else
DoCmd. OutputTo acOutputQuery, stDocName, "ExcelWorkbook (*.xlsx)", "log .xlsx", True
End Select

This method to me in basis used... But it does not format a cell..., though the fast it is finite... There there are big comments, and the user if does not see all comment, starts to be nervous and runs into a stupor, and animation of filling of cells  labels on the first method produces on them magic action)... Well... At least while)

wrote:

to the Method xlBook. SaveAs it is possible to specify specific file type.
Interesting, and what file type at you turns out? On Excel 5.0 it so did not swear.

Anatoly, thanks for . If to make so:

filename = "the H: \catalogue \" both "" and ".xls"
xlBook. SaveAs filename, FileFormat: = 56

That is saved in XLS and does not swear at discovery.

9

Re: Export in Excel. The valid file format differs from specified by its extension.

(Kiev) wrote:

to the Method xlBook. SaveAs it is possible to specify specific file type.
Interesting, and what file type at you turns out? On Excel 5.0 it so did not swear.

At me by default it turned out xlsx probably... And I gave the extension to it xls, here she and swore at discovery.
About Excel 5.0 , at users costs 2010 (Excel) and above... Basis of a current under 2003 .