Skipping the "Overwrite" warning within a Macro
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 -- Sincerely, Beverly76 |
Skipping the "Overwrite" warning within a Macro
Use.
Application.DisplayAlerts = False Make sure to turn the alerts back on at the end of your code by setting the above to true. Beverly76 wrote: 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 -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200809/1 |
All times are GMT +1. The time now is 09:27 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com