Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to Convert XLS File into a CSV File

1 view
Skip to first unread message

RamaKrishnan

unread,
May 18, 2006, 7:55:35 AM5/18/06
to
Hello Friends,
I am having a File in XLS Format. I need To convert this file to CSV File
Format. through visual basic Code


With Regards,
Rama


Norm Cook

unread,
May 18, 2006, 8:34:46 AM5/18/06
to
ActiveWorkbook.SaveAs Filename:="C:\VB6\0MyStuff\Disposal\Book1.csv", _
FileFormat:=xlCSV, CreateBackup:=False

"RamaKrishnan" <ra...@cspl.com> wrote in message
news:euPdmHne...@TK2MSFTNGP03.phx.gbl...

For most Office/VBA products, you can
1) Start a Macro
2) Do the SaveAs or whatever
3) Stop the Macro
4) View the VBA source for the Macro

In this case I get something like:
ActiveWorkbook.SaveAs Filename:="C:\YourPath\YourSheet.csv", _
FileFormat:=xlCSV, CreateBackup:=False


Paul Clement

unread,
May 18, 2006, 12:41:32 PM5/18/06
to
On Thu, 18 May 2006 17:25:35 +0530, "RamaKrishnan" <ra...@cspl.com> wrote:

¤ Hello Friends,


¤ I am having a File in XLS Format. I need To convert this file to CSV File
¤ Format. through visual basic Code

¤

Sub ExportExcelToText()

Dim cnn As New ADODB.Connection
Dim strSQL As String

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

strSQL = "SELECT * INTO [Text;DATABASE=C:\Documents and Settings\...\My Documents\My
Database\Text].[ReportSheet.csv] FROM [ReportSheet$]"

cnn.Execute strSQL

cnn.Close

Set cnn = Nothing

End Sub


Paul
~~~~
Microsoft MVP (Visual Basic)

Chris

unread,
Jul 6, 2006, 2:28:02 PM7/6/06
to
Hi,

I am not to familiar with this, from the last post I don't get this line:

strSQL = "SELECT * INTO [Text;DATABASE=C:\Documents and Settings\...\My
Documents\My Database\Text].[ReportSheet.csv] FROM [ReportSheet$]"

what should I put in the [ReportSheet$] field?

Thanks in advance

Chris

Paul Clement

unread,
Jul 6, 2006, 2:41:34 PM7/6/06
to
On Thu, 6 Jul 2006 11:28:02 -0700, Chris <Ch...@discussions.microsoft.com> wrote:

¤ Hi,


¤
¤ I am not to familiar with this, from the last post I don't get this line:
¤
¤ strSQL = "SELECT * INTO [Text;DATABASE=C:\Documents and Settings\...\My
¤ Documents\My Database\Text].[ReportSheet.csv] FROM [ReportSheet$]"
¤
¤ what should I put in the [ReportSheet$] field?

¤

That would be the name of the Worksheet in the Workbook that you are exporting.

0 new messages