Save using a Macro

N

Nick

I have a macro set up to save a worksheet. I always save
it in the same place with the same file name.
What I would like is for the macro to overwrite the file
and then close Excel without prompting.
Sub Backlog()
'
' Backlog Macro
' Macro recorded 07/11/2003 by HFRUPN
'

'
ChDir "G:\Crushing Shedules\Backlog"
ActiveWorkbook.SaveAs Filename:="G:\Crushing
Shedules\Backlog\BACKLOG.xls", _
FileFormat:=xlNormal, Password:="",
WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

End Sub
Can this be done?

Regards
Nick
 
F

Frank Kabel

Hi
try
Sub Backlog()
'
' Backlog Macro
' Macro recorded 07/11/2003 by HFRUPN
'

'
ChDir "G:\Crushing Shedules\Backlog"
application.displayalerts = false
ActiveWorkbook.SaveAs Filename:="G:\Crushing
Shedules\Backlog\BACKLOG.xls", _
FileFormat:=xlNormal, Password:="",
WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
application.displayalerts = True
End Sub
 
B

Bob Phillips

Nick,

If you really want to close Excel, then use

Application.Quit

--

HTH

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

Nick

Thank you for you help.
The Quit command works well but unfortunately I can’t get
the save to work. I get the message “A filenamed ----
Already exists in this location. Do you want to replace
it.” Yes, No or Cancel.
I would like it to save without prompting

Regards
Nick
 
B

Bob Phillips

Frank gave the code for that, precede the Save with

application.displayalerts = false

and reset after with

application.displayalerts = True

--

HTH

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

nick

Success!
Thank you both very much. I have been pondering this for
some time.
I really appreciate your help.

Nick
 

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