
Exporting Excel file to CSV formatted file.
I am writing a VB6 utility that will extract data from a
MS Excel 2000 file and outputs to a CSV formatted file. I
know how to read an Excel file and output to a text file
but don't know how to output to CSV.
Any help, suggestions would be highly appreciated.
Sub ExportToTextFromExcel()
Dim cnn As New ADODB.Connection
Dim sqlString As String
cnn.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=D:\My Documents\Book2.xls;Extended Properties=Excel 8.0;"
'sqlString = "SELECT * INTO [Text;DATABASE=D:\My Documents\TextFiles].[Sheet4.csv] FROM
[Sheet1$A3:D7]"
sqlString = "SELECT * INTO [Text;DATABASE=D:\My Documents\TextFiles].[Sheet4.csv] FROM [Sheet4]"
cnn.Execute sqlString
cnn.Close
Set cnn = Nothing
End Sub
Microsoft MVP (Visual Basic)