ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automatically Answer YES for Pop Up Msg Box (https://www.excelbanter.com/excel-programming/295596-automatically-answer-yes-pop-up-msg-box.html)

Holger Friebe

Automatically Answer YES for Pop Up Msg Box
 
Hello,.

by default I would like to program my excel application so that it
automatically overwrite an existing file w/o asking a question if I want to
overwrite that existing file.

In other words:
In my code it says:

ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\Holger Friebe\My Documents\My
Work\Performancebiz.xls" _
, FileFormat:=xlExcel9795, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False,
ConflictResolution:=xlLocalSessionChanges
Workbooks("Performancebiz.xls").Close SaveChanges:=False

This code triggers a message box which basically asks me if I want to
overwrite the existing file.
The default is set to NO.

I would like to
- not to the program ask me that message box question (I found a way how to
do that) and
- to then answer the question as a default with YES.

How can I program this to set to make the program automatically answer YES
and therefore automatically overwrite the existing file?

Thank you for your help.

Holger



Frank Kabel

Automatically Answer YES for Pop Up Msg Box
 
Hi
put the line
application.displayalerts = False
before your save codeand
application.displayalerts = True
after this saving code

--
Regards
Frank Kabel
Frankfurt, Germany


Holger Friebe wrote:
Hello,.

by default I would like to program my excel application so that it
automatically overwrite an existing file w/o asking a question if I
want to overwrite that existing file.

In other words:
In my code it says:

ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\Holger Friebe\My Documents\My
Work\Performancebiz.xls" _
, FileFormat:=xlExcel9795, Password:="",
WriteResPassword:="", _ ReadOnlyRecommended:=False,
CreateBackup:=False, ConflictResolution:=xlLocalSessionChanges
Workbooks("Performancebiz.xls").Close SaveChanges:=False

This code triggers a message box which basically asks me if I want to
overwrite the existing file.
The default is set to NO.

I would like to
- not to the program ask me that message box question (I found a way
how to do that) and
- to then answer the question as a default with YES.

How can I program this to set to make the program automatically
answer YES and therefore automatically overwrite the existing file?

Thank you for your help.

Holger



Holger Friebe

Automatically Answer YES for Pop Up Msg Box
 
Hello Frank,

thank you for your fast answer.

"Frank Kabel" wrote in message
...
Hi
put the line
application.displayalerts = False
before your save code and
application.displayalerts = True
after this saving code


I would like to
- not to the program ask me that message box question (I found a way
how to do that) and


I tried your proposal before to do what I state above. The trouble is that
due to the fact that the default is set to continue with NO the intended
overwriting of the file does not happen! Therefore I have to not only find a
way to hide the display as your code definitely does but also to change the
default answer before the code continues on.

- to then answer the question as a default with YES.

How can I program this to set to make the program automatically
answer YES and therefore automatically overwrite the existing file?


Thank you for your help.

Holger




All times are GMT +1. The time now is 05:31 AM.

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