Archive of Mr Excel Message Board

Back to Excel VBA archive index
Back to archive home

"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?
Stan

| Check out our Excel VBA Resources
|
 |
 |
 |
 |
 |
Use xlDialogSaveAs - Here's the code.
Posted by Rick E on November 23, 2001 12:06 PM
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"
Else
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

Thanks Rick - works great!
Posted by Stan on November 23, 2001 12:19 PM

This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our
online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.