Excel Macro to convert xlsx to xls -
Excel Macro to convert xlsx to xls -
i have bunch of files in folder of them in xlsx
format, need convert them xls
format. going done on daily bases.
i need macro loop around folder , convert file xls xlsx out changing file name.?
here macro using loop
sub processfiles() dim filename, pathname string dim wb workbook pathname = activeworkbook.path & "c:\users\myfolder1\desktop\myfolder\macro\" filename = dir(pathname & "*.xls") while filename <> "" set wb = workbooks.open(pathname & filename) dowork wb wb.close savechanges:=true filename = dir() loop end sub
what missing instead of calling wb.close savechanges=true
save file in format, need phone call wb.saveas
new file format , name.
you said want convert them without changing file name, suspect meant want save them same base of operations file name, .xls
extension. if workbook named book1.xlsx
, want save book1.xls
. calculate new name can simple replace()
on old name replacing .xlsx
extension .xls
.
you can disable compatibility checker setting wb.checkcompatibility
, , suppress alerts , messages setting application.displayalerts
.
sub processfiles() dim filename, pathname, savefilename string dim wb workbook dim initialdisplayalerts boolean pathname = "<insert_path_here>" ' needs have trailing \ filename = dir(pathname & "*.xlsx") initialdisplayalerts = application.displayalerts application.displayalerts = false while filename <> "" set wb = workbooks.open(filename:=pathname & filename, _ updatelinks:=false) wb.checkcompatibility = false savefilename = replace(filename, ".xlsx", ".xls") wb.saveas filename:=pathname & savefilename, _ fileformat:=xlexcel8, password:="", writerespassword:="", _ readonlyrecommended:=false, createbackup:=false wb.close savechanges:=false filename = dir() loop application.displayalerts = initialdisplayalerts end sub
excel excel-vba
Comments
Post a Comment