excel vba‎ > ‎

VBA - Define Dir Path and Save As

posted Sep 30, 2010, 7:13 AM by Roberto Felicini   [ updated Sep 30, 2010, 1:17 PM ]
    Path = ActiveWorkbook.Path
    ChDrive Path
    fname = Application.GetSaveAsFilename _
            (InitialFileName:=Range("example"), _
            fileFilter:="Excel Files (*.XLS), *.XLS", _
                         Title:="Save As")
    If fname = False Then
        MsgBox "User pressed cancel, the file will be not saved!"
        ActiveWorkbook.Close False
    Else
        Application.DisplayAlerts = False
        ActiveWorkbook.SaveAs Filename:=fname
        Application.DisplayAlerts = True
        ActiveWorkbook.Close False
        MsgBox "Saving as " & fname, vbInformation
    end if
 
Comments