excel - VBA converting csv Files in a folder to xlsx Files -
i have code.
this code converts xlsm files.
i want convert xlsx files.
how?
i tried changing
wbook.saveas xlsfolder & replace(fname, ".csv", ""), thisworkbook.fileformatto wbook.saveas xlsfolder & replace(fname, ".csv", ".xlsx")
it didn't worked.
private sub commandbutton2_click() dim csvfolder string dim xlsfolder string dim fname string dim wbook workbook csvfolder = "c:\csv\" xlsfolder = "c:\charts\" fname = dir(csvfolder & "*.csv") while fname <> "" set wbook = workbooks.open(csvfolder & fname, format:=6, delimiter:=",") wbook.saveas xlsfolder & replace(fname, ".csv", ""), thisworkbook.fileformat wbook.close false fname = dir loop end sub
using macro recoder, file format xlsx
workbook fileformat:=xlopenxmlworkbook
so here code :
private sub commandbutton2_click() dim csvfolder string, _ xlsfolder string, _ fname string, _ wbook workbook csvfolder = "c:\csv\" xlsfolder = "c:\charts\" fname = dir(csvfolder & "*.csv") while fname <> "" set wbook = workbooks.open(csvfolder & fname, format:=6, delimiter:=",") wbook.saveas xlsfolder & replace(fname, ".csv", ""), xlopenxmlworkbook wbook.close false fname = dir loop end sub
Comments
Post a Comment