Thursday, 15 April 2010

excel - Saving files as CSV using VBA - currently saving multiple files as worksheets -



excel - Saving files as CSV using VBA - currently saving multiple files as worksheets -

my original problem finding out how separate file 12000 rows individual files 1000 rows , maintain header. found great q&a (with 1 adjustment number of rows), link here: how split spreadsheet multiple spreadsheets set number of rows?

the thing need script save files downwards csvs rather worksheets, can't see obvious in script defines file type me change. fyi, i'm very new this!

thanks in advance

as mentioned @vba4all in comments above, look workbook.saveas

expression .saveas(filename, fileformat, password, writerespassword, readonlyrecommended, createbackup, accessmode, conflictresolution, addtomru, textcodepage, textvisuallayout, local)

you can visit this msdn article read more it.

to save workbook csv, have use

activeworkbook.saveas filename:="c:\test.csv", fileformat:=xlcsv

please note when save workbook csv or without code, excel prompt confirmation. avoid can set application.displayalerts false

here example

application.displayalerts = false activeworkbook.saveas filename:="c:\test.csv", fileformat:=xlcsv application.displayalerts = true

to read more file formats, may want see this msdn link

excel vba excel-vba csv

No comments:

Post a Comment