ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Overwriting an existing workbook without having to click yes in the prompt box (https://www.excelbanter.com/excel-programming/296814-overwriting-existing-workbook-without-having-click-yes-prompt-box.html)

Ian M[_2_]

Overwriting an existing workbook without having to click yes in the prompt box
 
I want my macro to save a workbook called "accounts.xls", however I
may already have run the macro in which case I wish to over-write the
existing workbook.

If the file has already been saved under that name, the following
Excel dialogue box appears:

"do you wish to over-write the existing file?" in which I have to
click "YES"

I want the macro to find out whether a file called "accounts.xls"
already exists and, if so, delete it, so that the macro can save it
without the need for this Excel prompt box to appear.

Any ideas?

Thanks.

Ian M

Paul B[_6_]

Overwriting an existing workbook without having to click yes in the prompt box
 
Ian, try this it will not ask you if you want to over-write it will just do
it

Application.DisplayAlerts = False
'Your Code
Application.DisplayAlerts = True


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2000 & 97
** remove news from my email address to reply by email **
"Ian M" wrote in message
m...
I want my macro to save a workbook called "accounts.xls", however I
may already have run the macro in which case I wish to over-write the
existing workbook.

If the file has already been saved under that name, the following
Excel dialogue box appears:

"do you wish to over-write the existing file?" in which I have to
click "YES"

I want the macro to find out whether a file called "accounts.xls"
already exists and, if so, delete it, so that the macro can save it
without the need for this Excel prompt box to appear.

Any ideas?

Thanks.

Ian M




Ian M[_2_]

Overwriting an existing workbook without having to click yes in the prompt box
 
Thanks Paul

It works perfectly.

Many thanks for your help.

Kind regards

Ian M



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 01:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com