Disable "Are you sure you want to overwrite worksheet&q

ificouldpaint

New Member
Joined
Feb 16, 2006
Messages
24
Hi everyone,
I'm in a bit of a pickle, I have VBA code adding a new workbook which then uses the SaveAs method to overwrite an existing workbook. This throws the standard alert up on screen which says "Are you sure you want to overwrite worksheet" or something along those lines. I need this to be disabled.

Looking at the displayalerts property this isn't going to be possible.

Does anyone know how this can be done.

Regards

Ificouldpaint
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Re: Disable "Are you sure you want to overwrite workshe

Looking at the displayalerts property this isn't going to be possible.
Why not?

Doesn't this do what you want?
Application.DisplayAlerts = False
Your code here
Application.DisplayAlerts = True
 
Upvote 0
As Peter says, you can disable the alerts purely for the WorkbookSaveAs command, and then turn it back on again for the rest of your code.

Richard
 
Upvote 0
Sorry just saw an article on Microsoft which clarified

Sorry just saw an article on Microsoft which clarified the help file in excel.

Apparently application.DisplayAlerts = False will disables the error box for file overwrite.


This extract from the help file confused me... however it does actually make sense.

When using the SaveAs method for workbooks to overwrite an existing file, the 'Overwrite' alert has a default of 'No', while the 'Yes' response is selected by Excel when the DisplayAlerts property is set equal to True.

Regards

Ificouldpaint
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,749
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top