Excel Macro is not closing CSV files when process is done -



Excel Macro is not closing CSV files when process is done -

i running next script , seems not closing , files when script run . how can edit script can close script .

sub loopfiles() dim myfilename string, mypath string application.screenupdating = false application.displayalerts = false mypath = "c:\macro\" myfilename = dir(mypath & "*.xlsx") chdir "c:\macro\csv" until myfilename = "" workbooks.open filename:=mypath & myfilename activeworkbook.saveas filename:=left(myfilename, instr(1, myfilename, ".xlsx") - 1), fileformat:=xlcsv, createbackup:=false myfilename = dir loop application.screenupdating = true application.displayalerts = true end sub

add line: activeworkbook.close false

in space have demonstrated below.

do until myfilename = "" workbooks.open filename:=mypath & myfilename activeworkbook.saveas filename:=left(myfilename, instr(1, myfilename, ".xlsx") - 1), fileformat:=xlcsv, createbackup:=false activeworkbook.close false myfilename = dir loop

or cleaner version this:

dim wkb workbook until myfilename = "" set wkb = workbooks.open(filename:=mypath & myfilename) wkb .saveas filename:=left(myfilename, instr(1, myfilename, ".xlsx") - 1), fileformat:=xlcsv, createbackup:=false .close false end loop

excel excel-vba

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -