jjxia2001
asked on
How to code to save a file with a suggested name and in a selected folder
I need create a save button for saving the file with a suggested name in the file name box but being able to choose where they want to save and have the default to C:\drive
Sub btnSave_Click()
.....
.....
End Sub
Sub btnSave_Click()
.....
.....
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I forgot to mention that the file name needs a option to be overwriiten and as Excel file
You could check the Cancel button by checking if the fileName is False.
As for your last remark: I'm not sure what you mean by 'file name needs a option to be overwritten'?
Do you mean in the 'Save As' Dialog?
As for your last remark: I'm not sure what you mean by 'file name needs a option to be overwritten'?
Do you mean in the 'Save As' Dialog?
Sub saveTheFile()
'get the name and folder
Filename = Application.GetSaveAsFilename( _
InitialFileName:="C:\yourFileName.xlsm", _
fileFilter:="Excel Macro-Enabled Workbook (*.xlsm), *.xlsm, Excel 97 Workbook (*.xls), *.xls")
'save if not canceled
If Filename <> False Then
Application.ThisWorkbook.SaveAs (Filename)
End If
End Sub
ASKER
Works! Thanks!
ASKER