I have an excel template that uses a macro to save the file, so that the users maintain standardized file name formats. I created the code using Excel 2003. the code is as follows:
Sub SaveBook()
Dim sFile As String
sFile = "ConsolidatedDemand" & "_" & Format(Now(), "yyyy.mm.dd") & ".xls"
ActiveWorkbook.SaveAs Filename:= "\\file location\" & sFile
End Sub
I have one user who uses Excel 2007. When they try to run the macro, they recieve an error:
“The following features can not be saved in macro-free workbooks: VB project.
To save a file with these features, click No, and then choose macro-enabled file type in the file type list. To continue saving as a macro-free workbook, click yes”
I tried chaing the file extension to “.xlsm” in the second line of code, but that yielded the same error message. Any other ideas of how I can modify this code so that it will work for Excel 2007 users?
(taken from: http://blogs.office.com/b/microsoft-excel/archive/2009/07/07/use-the-vba-saveas-method-in-excel-2007.aspx)
In Excel 2007, the SaveAs method requires you to provide both the FileFormat parameter and the correct file extension.
For example, in Excel 2007 this line of code will fail if the ActiveWorkbook is not an .xlsm file:
But this code will always work:
These are the main file formats in Excel 2007:
.xlsm)
macro’s, .xlsb)