ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Overwriting an existing Excel workbook (https://www.excelbanter.com/excel-discussion-misc-queries/122670-overwriting-existing-excel-workbook.html)

Jenni

Overwriting an existing Excel workbook
 
When I "save as" and overwrite an existing workbook I get the prompt "are you
sure you want to overwrite" is there any way to not get that prompt? To just
overwrite without warning?

Dave Peterson

Overwriting an existing Excel workbook
 
You mean in your macro?

If yes:

application.displayalerts = false
'your code to do .saveas
application.displayalerts = true

If you mean when you use file|saveas, I don't think so.

Jenni wrote:

When I "save as" and overwrite an existing workbook I get the prompt "are you
sure you want to overwrite" is there any way to not get that prompt? To just
overwrite without warning?


--

Dave Peterson

Jenni

Overwriting an existing Excel workbook
 
Yes in my macro would be great but if that cannot be done I was hoping there
is a way for me to "turn off" that warning temporarily while I run my macro.

"Dave Peterson" wrote:

You mean in your macro?

If yes:

application.displayalerts = false
'your code to do .saveas
application.displayalerts = true

If you mean when you use file|saveas, I don't think so.

Jenni wrote:

When I "save as" and overwrite an existing workbook I get the prompt "are you
sure you want to overwrite" is there any way to not get that prompt? To just
overwrite without warning?


--

Dave Peterson


Dave Peterson

Overwriting an existing Excel workbook
 
Do the "if yes" suggestion.

Jenni wrote:

Yes in my macro would be great but if that cannot be done I was hoping there
is a way for me to "turn off" that warning temporarily while I run my macro.

"Dave Peterson" wrote:

You mean in your macro?

If yes:

application.displayalerts = false
'your code to do .saveas
application.displayalerts = true

If you mean when you use file|saveas, I don't think so.

Jenni wrote:

When I "save as" and overwrite an existing workbook I get the prompt "are you
sure you want to overwrite" is there any way to not get that prompt? To just
overwrite without warning?


--

Dave Peterson


--

Dave Peterson

[email protected]

Overwriting an existing Excel workbook
 
In Excel 2003 you need to set this before calling SaveAs:
DisplayAlerts = False
AlertBeforeOverwriting = False

In this Excel version, DisplayAlerts = False does not suppress the
overwrite warning. To make very sure that you are never prompted, it is
recommended that you also use the ConflictResolution parameter of
SaveAs, like this:

ActiveWorkbook.SaveAs Filename:="name to be used",
FileFormat:=xlNormal, ConflictResolution:=xlLocalSessionChanges

Best regards,

Berend


Dave Peterson schreef:

Do the "if yes" suggestion.

Jenni wrote:

Yes in my macro would be great but if that cannot be done I was hoping there
is a way for me to "turn off" that warning temporarily while I run my macro.

"Dave Peterson" wrote:

You mean in your macro?

If yes:

application.displayalerts = false
'your code to do .saveas
application.displayalerts = true

If you mean when you use file|saveas, I don't think so.

Jenni wrote:

When I "save as" and overwrite an existing workbook I get the prompt "are you
sure you want to overwrite" is there any way to not get that prompt? To just
overwrite without warning?

--

Dave Peterson


--

Dave Peterson



Dave Peterson

Overwriting an existing Excel workbook
 
From xl2003's help for AlertBeforeOverwriting...

True if Microsoft Excel displays a message before overwriting nonblank cells
during a drag-and-drop editing operation. Read/write Boolean.

That's the setting you can toggle via Tools|Options|Edit tab|under the allow
cell drag and drop box.

I've never seen xl2003 show the warning prompt when I've used
"application.displayalerts = false"

And the Conflictresolution setting has to do with shared workbooks. If the
workbook isn't shared, this won't have any effect.

Also from xl2003's help for the ConflictResolution Property:

Returns or sets the way conflicts are to be resolved whenever a shared workbook
is updated. Read/write XlSaveConflictResolution.

XlSaveConflictResolution can be one of these XlSaveConflictResolution constants.
xlLocalSessionChanges. The local user's changes are always accepted.
xlOtherSessionChanges. The local user's changes are always rejected.
xlUserResolution. A dialog box asks the user to resolve the conflict.


wrote:

In Excel 2003 you need to set this before calling SaveAs:
DisplayAlerts = False
AlertBeforeOverwriting = False

In this Excel version, DisplayAlerts = False does not suppress the
overwrite warning. To make very sure that you are never prompted, it is
recommended that you also use the ConflictResolution parameter of
SaveAs, like this:

ActiveWorkbook.SaveAs Filename:="name to be used",
FileFormat:=xlNormal, ConflictResolution:=xlLocalSessionChanges

Best regards,

Berend

Dave Peterson schreef:

Do the "if yes" suggestion.

Jenni wrote:

Yes in my macro would be great but if that cannot be done I was hoping there
is a way for me to "turn off" that warning temporarily while I run my macro.

"Dave Peterson" wrote:

You mean in your macro?

If yes:

application.displayalerts = false
'your code to do .saveas
application.displayalerts = true

If you mean when you use file|saveas, I don't think so.

Jenni wrote:

When I "save as" and overwrite an existing workbook I get the prompt "are you
sure you want to overwrite" is there any way to not get that prompt? To just
overwrite without warning?

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson

[email protected]

Overwriting an existing Excel workbook
 
I have re-tested, and you are right about the AlertBeforeOverwriting
not making any difference (as it shouldn't). Actually, on my machine I
*always* got an overwrite prompt from VBA with the test code that I
tried. It works properly from the Interop in C#, I stupidly assumed
that my tinkering with the global flag did that.


Dave Peterson schreef:

From xl2003's help for AlertBeforeOverwriting...

True if Microsoft Excel displays a message before overwriting nonblank cells
during a drag-and-drop editing operation. Read/write Boolean.

That's the setting you can toggle via Tools|Options|Edit tab|under the allow
cell drag and drop box.

I've never seen xl2003 show the warning prompt when I've used
"application.displayalerts = false"

And the Conflictresolution setting has to do with shared workbooks. If the
workbook isn't shared, this won't have any effect.

Also from xl2003's help for the ConflictResolution Property:

Returns or sets the way conflicts are to be resolved whenever a shared workbook
is updated. Read/write XlSaveConflictResolution.

XlSaveConflictResolution can be one of these XlSaveConflictResolution constants.
xlLocalSessionChanges. The local user's changes are always accepted.
xlOtherSessionChanges. The local user's changes are always rejected.
xlUserResolution. A dialog box asks the user to resolve the conflict.


wrote:

In Excel 2003 you need to set this before calling SaveAs:
DisplayAlerts = False
AlertBeforeOverwriting = False

In this Excel version, DisplayAlerts = False does not suppress the
overwrite warning. To make very sure that you are never prompted, it is
recommended that you also use the ConflictResolution parameter of
SaveAs, like this:

ActiveWorkbook.SaveAs Filename:="name to be used",
FileFormat:=xlNormal, ConflictResolution:=xlLocalSessionChanges

Best regards,

Berend

Dave Peterson schreef:

Do the "if yes" suggestion.

Jenni wrote:

Yes in my macro would be great but if that cannot be done I was hoping there
is a way for me to "turn off" that warning temporarily while I run my macro.

"Dave Peterson" wrote:

You mean in your macro?

If yes:

application.displayalerts = false
'your code to do .saveas
application.displayalerts = true

If you mean when you use file|saveas, I don't think so.

Jenni wrote:

When I "save as" and overwrite an existing workbook I get the prompt "are you
sure you want to overwrite" is there any way to not get that prompt? To just
overwrite without warning?

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson




All times are GMT +1. The time now is 08:14 AM.

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