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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -