By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,215 Members | 1,936 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,215 IT Pros & Developers. It's quick & easy.

How to open an Excel file and save a copy as CSV programatically?

P: n/a
How can I open an Excel file then SAVE AS .CSV file using VB.NET?

Thanks
Bill
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Tue, 24 May 2005 21:03:42 -0700, "Bill nguyen" <bi*****************@jaco.com> wrote:

How can I open an Excel file then SAVE AS .CSV file using VB.NET?


You can use ADO.NET to do this:

Dim ExcelConnection As New
System.Data.OleDb.OleDbConnection("Provider=Micros oft.Jet.OLEDB.4.0;" & _
"Data Source=e:\My Documents\Book20.xls;Extended Properties=""Excel
8.0;HDR=NO;IMEX=1""")

ExcelConnection.Open()

Dim ExportCommand As New System.Data.OleDb.OleDbCommand("SELECT * INTO [Text;DATABASE=E:\My
Documents\TextFiles].[Sheet4.csv] FROM [Sheet4$]")

ExportCommand.ExecuteNonQuery()
ExcelConnection.Close()
Paul
~~~~
Microsoft MVP (Visual Basic)
Nov 21 '05 #2

P: n/a
Thanks Paul.
I'll try it right away.
Thanks
Bill
"Paul Clement" <Us***********************@swspectrum.com> wrote in message
news:67********************************@4ax.com...
On Tue, 24 May 2005 21:03:42 -0700, "Bill nguyen"
<bi*****************@jaco.com> wrote:

How can I open an Excel file then SAVE AS .CSV file using VB.NET?


You can use ADO.NET to do this:

Dim ExcelConnection As New
System.Data.OleDb.OleDbConnection("Provider=Micros oft.Jet.OLEDB.4.0;" & _
"Data Source=e:\My Documents\Book20.xls;Extended
Properties=""Excel
8.0;HDR=NO;IMEX=1""")

ExcelConnection.Open()

Dim ExportCommand As New System.Data.OleDb.OleDbCommand("SELECT *
INTO [Text;DATABASE=E:\My
Documents\TextFiles].[Sheet4.csv] FROM [Sheet4$]")

ExportCommand.ExecuteNonQuery()
ExcelConnection.Close()
Paul
~~~~
Microsoft MVP (Visual Basic)

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.