PDA

View Full Version : CSV File



mufasa
04-23-2008, 02:36 AM
Hi There

How do I change the code to save it as a comma dellimited CSV text file, At the moment it saves it as a csv file but it open is Excel.

FileName = Application.GetSaveAsFilename( _
fileFilter:="CSV Files (*.csv), *.csv")
If FileName <> False Then

ActiveWorkbook.SaveAs FileName
ActiveWorkbook.Close
End If

thx

tstav
04-23-2008, 02:54 AM
Haven't tried it ever, but according to Help (place cursor inside the word 'SaveAs', press F1 and then choose 'Workbook'), it's
ActiveWorkbook.SaveAs FileName, xlCSV

mdmackillop
04-23-2008, 04:04 AM
Excel can open CSV files so you may see it displayed. It is not a workbook though, and cannot be saved with multiple sheets and other Excel features.

Jow
04-23-2008, 04:50 AM
A CSV file will open in Excel if you have Excel set as the default program to open that file type.

If you want CSV files to open in Notepad, right-click on any of your CSV files, go to 'properties' and then change the program that CSV files will open in, commonly notepad.

mufasa
04-23-2008, 05:47 AM
Thx

ActiveWorkbook.SaveAs FileName, xlCSVMSDOS

mufasa
04-23-2008, 06:07 AM
One thing I noticed now is that if I have data in colum C, F J the CSV file should be similar to ,,X,,,X,,,,X but it gives me the output as X,,,X,,,,X. It basically drops the first three commas.

Do any of you have an Idea how I can fix this?

Also is there a way that can replace the commas with a |(Pipe symbol)?

thx