Hi,
I have a code to "save as". But I don't get any error message or similar if I try to override an already existing file with the same name..
What property to add for that?
Here's the code:
I have a code to "save as". But I don't get any error message or similar if I try to override an already existing file with the same name..
What property to add for that?
Here's the code:
Code:
Private Sub LagreSomExcel ()
Dim fileSaveName As Variant
Prosjekt = Sheets("Forside").Range("E3").Value
Rapportnavn = Range("C2").Value
fileName = Prosjekt & "_" & Rapportnavn
fileSaveName = Application.GetSaveAsFilename(initialFilename:=fileName)
If VarType(fileSaveName) = vbBoolean Then Exit Sub
fileSaveName = Left(fileSaveName, Len(fileSaveName) - 1)
' Save as XLSM
ActiveWorkbook.SaveAs fileName:=fileSaveName & ".xlsm", _
FileFormat:=xlOpenXMLWorkbookMacroEnabled
End sub