×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Command to Open "Save As..." Window

Command to Open "Save As..." Window

Command to Open "Save As..." Window

(OP)
I'm trying to write a macro that on a button click, opens another file then opens the "Save As" window so that the user can enter a new file name and location of their choosing.  I have no problem opening the file, but the ActiveWorkbook.Save As command wants to actually perform the save as function immediately.  I just want the macro to end by leaving the Save As window open.

Thoughts?

-Mike

RE: Command to Open "Save As..." Window

Mike,

There are a couple of ways to do this.  Here are two  procedures that demonstrate the general ideas:

Sub ActiveWorkbookSaveAs()
Dim FName As String

  FName = Application.GetSaveAsFilename(InitialFilename:="", FileFilter:="Microsoft Excel Workbook (*.xls),*.xls")
  If FName <> "False" Then
    ActiveWorkbook.SaveAs FName
  End If
End Sub


OR

Sub ActiveWorkbookSaveAs()
Dim Result As Boolean
  Result = Application.Dialogs(xlDialogSaveAs).Show
End Sub


Notes:  Set InitialFilename to a nonempty string to display a suggested filename.  FileFilter can include multiple file types.  Keep in mind that GetFilenameSaveAs only returns a file path and name as a string.  You can do whatever you want with this; in this case, you are supplying it to the SaveAs method.

Look at the VBA Help for the GetFilenameSaveAs method and the Dialogs collection (built-in Excel dialogs) for more detail as well as additional parameters.


Regards,
Mike

RE: Command to Open "Save As..." Window

(OP)
Mike,

Excellent!  This is just what I was looking for.  Thanks.

-Mike

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources