How to pass unique custom file name to Save Dialog

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an Excel template and when the user saves his workfile, I would like
to generate an unique file and pass it to the save dialog. Any help is
appreciated.
 
You can use the SaveAs method and set your file name up as a combination of
User Name, topic and date. You and use the InputBox method to get the user
name as a variable and use the format function to set the date as a string.

userName = InputBox("Enter your name (1st or last?)", "User Name"
fName = userName & Format(Now, "dmmmyy") & "Topic"
wb.SaveAs fileName:=fName
 
Or you could use this:

Set NewBook = Workbooks.Add
fName = Application.GetSaveAsFilename
NewBook.SaveAs Filename:=fName

which adds a new workbook and then displays the SaveAs Dialog Box so you can
enter any file name you like and choose the type file extension.
 
Back
Top