Skip to main content

Posts

Showing posts with the label Saving .xlsx file as .xls file by macro code in excel

Saving .xlsx file as .xls file by macro code in excel

Sub SaveAs(Filename As String, Format As String) 'XLS Format If UCase(Format) = "XLS" Then ActiveWorkbook.SaveAs Filename:= _ Filename, FileFormat:= _ xlExcel8, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _ , CreateBackup:=False Else 'default 'XLSX Format ActiveWorkbook.SaveAs Filename:= _ Filename, FileFormat:= _ xlOpenXMLWorkbook, CreateBackup:=False End If End Sub Sub Test() SaveAs "C:\tmp\Filename.xls", "xlsx" SaveAs "C:\tmp\Filename.xlsx", "xls" End Sub