I am trying to just have this save a file with a given name. I keep getting a "Method 'SaveAs' of object'_Workbook' failed error". If I change ".xlsm" to ".xls" it will save in the right path but as soon as I add the m I get an error. Any thoughts?
Code
Sub save()
Dim path As String
Dim filename As String
Dim d As String
Dim b As String
Dim f As String
Dim a As String
Dim iyear As String
iyear = Year(Date)
d = DateAdd("m", -1, Now)
b = Month(d)
f = MonthName(b)
a = Format(d, "mm") & ". " & f & " " & iyear
filename = "RFM" & f & " " & iyear & ".xlsm"
ActiveWorkbook.SaveAs filename:="\\office\Group11\T&A\Data Specialist\RFT REPORT\Source Reports\" & iyear & "\" & a & "\" & filename, _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub
Display More