ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using a macro to save a file. (https://www.excelbanter.com/excel-programming/312563-using-macro-save-file.html)

Menoh

Using a macro to save a file.
 
I need to find out how to write a macro that brings up the save as dialog
box, lets the user enter in where to save the document as well as the name of
the document, then after it's saved continue with the rest of the macro.

Frank Kabel

Using a macro to save a file.
 
Hi
in the VBA help have a look at:
application.GetSaveAsFilename

--
Regards
Frank Kabel
Frankfurt, Germany

"Menoh" schrieb im Newsbeitrag
...
I need to find out how to write a macro that brings up the save as

dialog
box, lets the user enter in where to save the document as well as the

name of
the document, then after it's saved continue with the rest of the

macro.


Tom Ogilvy

Using a macro to save a file.
 
Dim fName as String

' code before the save

fname = Application.GetSaveAsFilename()
if fName < "False" then
activeworkbook.SaveAs fName
End if

' code after the save


fName will equal "False" if the user hits cancel - not sure what you want to
do in that case. Note that the save doesn't occur just by using the
dialog. The actuall save is done with Activeworkbook.SaveAs.

Also, if you want to silently overwrite an existing file with the selected
name

Application.Displayalerts = False
activeworkbook.SaveAs fName
Application.DisplayAlerts = True

--
Regards,
Tom Ogilvy

"Menoh" wrote in message
...
I need to find out how to write a macro that brings up the save as dialog
box, lets the user enter in where to save the document as well as the name

of
the document, then after it's saved continue with the rest of the macro.





All times are GMT +1. The time now is 07:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com