how to extract excel file data into text file.

G

gujarsachin2001

Hi friends,

I m just stuck with extracting excel file data into text file.
So can any body please help me out.
thx,
Sachin.
 
P

Paul Clement

¤ Hi friends,
¤
¤ I m just stuck with extracting excel file data into text file.
¤ So can any body please help me out.
¤ thx,
¤ Sachin.

The following will export to a comma delimited file:

Dim ConnectionString As String

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Test Files\Book20.xls;Extended Properties=Excel 8.0;"

Dim ExcelConnection As New System.Data.OleDb.OleDbConnection(ConnectionString)
ExcelConnection.Open()

Dim SQLString As String = "SELECT * INTO [Text;DATABASE=C:\Documents and Settings\...\My
Documents\My Database\Text].[ReportSheet.txt] FROM [ReportSheet$]"

Dim ExcelCommand As New System.Data.OleDb.OleDbCommand(SQLString, ExcelConnection)
ExcelCommand.ExecuteNonQuery()

ExcelConnection.Close()


Paul
~~~~
Microsoft MVP (Visual Basic)
 
P

Paul Clement

¤ I'm trying something similar, but when I use the sample code provided I get
¤ the error message "Could not find installable ISAM" when I try to open the
¤ connection. I'm using Excel 2003 Version 11.6560.6568... Any ideas?
¤

This usually occurs when there is a syntax error in the connection string. You may want to post it
if you're still having an issue.


Paul
~~~~
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top