Reputation: 471
I need to make a VBA script that can take a complete copy of the current workbook and save it under a new name.
It need to be a complete copy with VBA scripts and everything.
The user may NOT be prompted for anything - the new file name (and location) will be provided by the code.
Upvotes: 1
Views: 29580
Reputation: 15226
I have noticed that at least for Excel 2013 ActiveWorkbook.SaveAs Filename:="C:\Data.xlsm
may not work as on my end it is saying that excel cannot save as file type xlsm.
However I did find a work around that is working for myself and wanted to add it here as a reference for others who may run into the same problem.
If you add , FileFormat:=52
after your code it will be able to save as the xlsm
format.
So this worked for me:
ActiveWorkbook.SaveAs Filename:="C:\Data.xlsm, FileFormat:=52"
Happy coding!
Upvotes: 1
Reputation: 26279
Surely something like this is sufficient?
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="C:\Data.xlsm"
Application.DisplayAlerts = True
Upvotes: 10