add the question `do you want to save or replace the file? ` prompt to be added in this script

Brass Contributor

i have this Macro to save the file with a cell value as a name which appear to be working, i would like to have the option to have the prompt asking me if i want to save or replace the file instead of have the file saved with out any kind of alert like in the following script.
once again thank you for your time

 

Option Explicit
Sub SvMe()
On Error Resume Next

'Saves filename as value of A1

Dim newFile As String, fName As String
fName = Range("D5").Value
newFile = fName & " "
ChDir _
"C:\Users\Paolo.De Luca\Documents\lETS PLAY WITH MACRO"
ActiveWorkbook.SaveAs Filename:=newFile

End Sub

1 Reply

@olopa67 

Try this version:

Sub SvMe()
    'Saves filename as value of D5
    Const fPath = "C:\Users\Paolo.De Luca\Documents\lETS PLAY WITH MACRO\"
    Dim newFile As String, fName As String
    fName = Range("D5").Value
    newFile = fPath & fName & ".xlsm"
    On Error Resume Next
    ActiveWorkbook.SaveAs Filename:=newFile, FileFormat:=xlOpenXMLWorkbookMacroEnabled
End Sub