We help IT Professionals succeed at work.

save Excel Macro-Enabled Workbook as Excel Workbook, using VBA.

Mohammad Alsolaiman
Mohammad Alsolaiman asked
on
Hello;
How to save Excel Macro-Enabled Workbook as Excel Workbook, using VBA.
help me please
Comment
Watch Question

byundtMechanical Engineer
Most Valuable Expert 2013
Top Expert 2013

Commented:
It is not clear which workbook is being saved: the active workbook, the one with the macro that is running, some other workbook.

Neither is it clear whether you want to save the workbook as .xls, .xlsx, .xlsm, or .xlsb file format.

Nor is it clear whether the code needs to run only on Windows Excel, or perhaps also on Mac Excel.

I suggest starting by reading Microsoft Excel MVP Ron de Bruin's webpage on the subject. In general, the SaveAs statement must include both Path & filename and the file format parameter. Omitting the file format parameter will lead to a runtime error when you later try to open the file. If it still isn't clear how to do what you want after reading that webpage, please post the specifics in a Comment.
Mechanical Engineer
Most Valuable Expert 2013
Top Expert 2013
Commented:
The statements in the following snippet save the active workbook in the same folder, but either as .xlsx, .xlsm, .xlsb or .xls file format. Choose the statement that saves the file in your preferred format, then modify the path and file name bits to suit.
ActiveWorkbook.SaveAs ActiveWorkbook.Path & Application.PathSeparator & "Some Name.xlsx", FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.SaveAs ActiveWorkbook.Path & Application.PathSeparator & "Some Name.xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled
ActiveWorkbook.SaveAs ActiveWorkbook.Path & Application.PathSeparator & "Some Name.xlsb", FileFormat:=xlExcel12
ActiveWorkbook.SaveAs ActiveWorkbook.Path & Application.PathSeparator & "Some Name.xls", FileFormat:=xlExcel8

Open in new window

Mohammad Alsolaimanapplication programmer

Author

Commented:
I have   Excel Macro-Enabled Workbook  which extension is (xlsm),  and I need to have a VBA code can save it as plain Excel Workbook which extension is (xlsx). only on Windows Excel.
Mohammad Alsolaimanapplication programmer

Author

Commented:
excelSheet
Mohammad Alsolaimanapplication programmer

Author

Commented:
Awesome
byundtMechanical Engineer
Most Valuable Expert 2013
Top Expert 2013
Commented:
Does this statement do what you want? I apologize for not adding the Arabic part of the file name.
ActiveWorkbook.SaveAs ActiveWorkbook.Path & Application.PathSeparator & "delete column by its name.xlsx", FileFormat:=xlOpenXMLWorkbook

Open in new window