MrExcel Publishing
Your One Stop for Excel Tips & Solutions

"File Save As" Macro

Posted by Stan on November 23, 2001 11:54 AM

I have an application where I've created my own custom menu bar. I would like to include a "File Save As" as a menu item. Is there a simple code that I can use to save a file?


Posted by Rick E on November 23, 2001 12:06 PM

Use xlDialogSaveAs - Here's the code.

Here is the code for a Save As Dialog Box:

Sub SaveIt()
Dim ck As Boolean
' SaveIt Macro
' Macro developed 11/6/2001 by Rick E
If newName = "" Then
str1 = "Enter New File Name Here"
str1 = newName
End If
ck = Application.Dialogs(xlDialogSaveAs).Show(str1)
If ck = True Then
newName = ActiveWorkbook.Name
End If
End Sub

newName is defined Public to all code.
ck is false if the Cancel button is used.
If called a second time the last file name is there.

Good Luck

Posted by Stan on November 23, 2001 12:19 PM

Thanks Rick - works great!