Using a macro to save a file.

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

Guest

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.
 
Hi
in the VBA help have a look at:
application.GetSaveAsFilename

--
Regards
Frank Kabel
Frankfurt, Germany

Menoh said:
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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top