Skipping the "Overwrite" warning within a Macro

B

Beverly76

I am trying to write a macro that opens a file, saves it under a separate
file name, then opens a different file and saves that, etc. I would like to
avoid Excel asking me if I want to overwrite the file within the macro. Is
there a way I can either turn off warnings, or more preferably indicate to
overwrite the file when in the code itself to avoid clicking "Yes" ten times.

This is what the editor has as the recorded code.
ChDir "S:\Test\Macros"
Workbooks.Open Filename:="S:\Test\Macros\MacroA.xls"
ChDir "S:\Test\Copies"
ActiveWorkbook.SaveAs Filename:="S:\Test\Copies\FileA.xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWindow.Close
 
D

dustinbrearton via OfficeKB.com

Use.
Application.DisplayAlerts = False
Make sure to turn the alerts back on at the end of your code by setting the
above to 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

Top