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
 

Some videos you may like

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
46,825
Office Version
  1. 365
Platform
  1. Windows
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
 

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
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
 

ificouldpaint

New Member
Joined
Feb 16, 2006
Messages
24
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
 

Watch MrExcel Video

Forum statistics

Threads
1,113,859
Messages
5,544,706
Members
410,630
Latest member
Maggie28
Top