LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming,microsoft.public.excel.misc
external usenet poster
 
Posts: 593
Default How to create a .XLS file instead of a .CSV file

keepITcool wrote ..

be careful with the syntax... SELECT INTO statement has several
"syntaxis" (see KB 295646), but this is the only way I got it to work
with both CSV and XLS in a "one-liner"


I prefer the alternative syntax e.g.

SELECT MyCol FROM [Excel
8.0;HDR=YES;Database=C:\Tempo\db.xls].MyTable

The sequence <<database.<<table is more logical, it avoids those
empty quotes and it better on the eye IMO <g.

note the the source file name cannot contain spaces!


This is incorrect (perhaps you were referring to a specific syntax
rather than generally?). You merely surround the file name (table
name) with e.g. brackets:

SELECT MyCol FROM [Text;Database=C:\Tempo\;].[Gappy Gap#csv];

I think your code is connecting to the wrong object i.e. the ADO
connection should be to Excel. As you said, because you connected to
the source and the source is Text you had syntax problems (a
limitation or bug in the provider?) You can open a connection to a
non-existent workbook; remember, the provider creates the workbook,
worksheet and Excel table on the fly if required. Also, with the
provider you are using (OLE DB for Jet 4.0), FMT=Delimited in the
connection string has no effect; you must use a scheme.ini file to
specify format, however comma delimited is default. Thus:

.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & xlsFile & ";" & _
"Extended Properties='Excel 8.0;HDR=Yes'"

.Execute _
"SELECT * " & _
" INTO Import " & _
" FROM [Text;HDR=Yes;Database=" & csvPath & ";].[" & csvFile &
"];"

Jamie.

--
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
create card file from csv file barb60185 Excel Discussion (Misc queries) 1 April 23rd 10 04:36 PM
Code to create dbase file from text file? Hilton Excel Discussion (Misc queries) 0 October 9th 08 10:37 AM
Possible to create XL file then run XL VBA (to format & filter XL file) from Access VBA? [email protected] Excel Discussion (Misc queries) 1 June 6th 08 06:37 AM
Create a single xls file with each import csv file having its own tab [email protected] Excel Discussion (Misc queries) 1 September 19th 07 08:38 PM
Create a batch file from a number of Excel File Vinay[_2_] Excel Programming 0 September 8th 04 01:11 AM


All times are GMT +1. The time now is 05:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"