GetSaveAsFilename method

D

Donna Brooks

This is the code I am using to save a report I am running.

fileSaveName = Application.GetSaveAsFilename
(fileFilter:="Excel Files (*.xls), *.xls")
If fileSaveName <> False Then
MsgBox "Save As " & fileSaveName
End If
ActiveWorkbook.Save
ActiveWindow.Close

How do I make it actually save the file as the name I
specify in the Save box? It just saves it as Book 1,2,
etc.

Thanks in Advance,
Donna Brooks
 
T

Tom Ogilvy

If fileSaveName <> False Then
ActiveWorkbook.SaveAs filename:= fileSaveName
End if
ActiveWorkbook.Close SaveChange:=False

Regards,
Tom Ogilvy
 
S

Stagerobbers

How can I set the path and allow the user to assign a file name and
ensure the file is saved to the path I set?

Thanks,

Dan
 
S

Stagerobbers

I tried the following code, but it returns: run time error 1004,
Application-defined or object-defined error. And it doesn't seem to
actually set the path.


CommandButton1 -click

Private Sub CommandButton1_Click()
ActiveWorkbook.SendMail "(e-mail address removed)", "test", True
Set Workbook = ActiveWorkbook
Do
fName = "C:\Documents and Settings\dan dungan\My
Documents\jones\backup\" & Application.GetSaveAsFilename
Loop Until fName <> False
ActiveWorkbook.SaveAs fName

End Sub
 
B

Bob Phillips

GetSaveAsFileName is a method that provides a dialog box to get a file name,
it doesn't save the file, it simply returns the file name of the file that
was selected.

You can direct GetSaveAsFileName at a particular directory by setting that
directory before, like so

ChDir "C:\Documents and Settings\dan dungan\My Documents\jones\backup\"
Do
fName = Application.GetSaveAsFilename
Loop Until fName <> False

ActiveWorkbook.SaveAs fName

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
T

Tom Ogilvy

Just to add, the dialog will start in that directory, but the user can
navigate to any directory. If you just want the user to supply a filename,
use an input box and have them type one in.
 

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

Top