I tried follow vb script, but not work, can some one hlep to rectify
Sub File_Save()
ActiveSheet.Name = Format(Now, "dd-mmm-yyyy")
Range("A1").Select
ActiveWorkbook.SaveAs Filename:="D:AGE00OH2104AMC" & ActiveSheet.Name & ".xls", FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Application.DisplayAlerts = Flase
ActiveWorkbook.Close
Range("A1").Select
End Sub
The macro work on a seprate Excel file but not in a macro workbook, which contains some other Macros
Hi David,
How exactly does it not work? If you are getting an error you need to tell us what it is.
When I try this code it works fine, with some minor modifications, like removing the Select statements.
I do have to change the save path from D:AGE00OH2104AMC to something that exists on my PC. Does that folder/path exist on your PC?
Sub File_Save()
ActiveSheet.Name = Format(Now, "dd-mmm-yyyy")
ActiveWorkbook.SaveAs Filename:="D:AGE00OH2104AMC" & ActiveSheet.Name & ".xls", FileFormat:=xlNormal
ActiveWorkbook.Close
End Sub
Are you sure you want a .xls file? Because your saving a macro in the workbook. I'm using Excel 2013, not sure what version you have. Check the file formats
https://docs.microsoft.com/en-us/office/vba/api/excel.xlfileformat
Regards
Phil
Hi David,
I've just seen your 2nd post. Perhaps the issue is that the other workbook is a .xlsm file?
Again, without the exact error message it's difficult to give advice.
Phil
Thanks so much Philip!
Yes , agreed it works with a separate file but not work in a Macro workbook.
I capture the screen for reference but sorry they are in Chinese, basically it tells the property of the syntex is not well defined or something like the
parameter is not correctly set
Philip, thanks again your effort
Then, how to write the Macro to auto save the file in xlsx OR xlsm format,
and at the same time the Work book structure and the Macro is protected.