ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to stop a msgbox pop up from another workbook (https://www.excelbanter.com/excel-programming/392152-how-stop-msgbox-pop-up-another-workbook.html)

Steve O

How to stop a msgbox pop up from another workbook
 
I have a workbook that opens another workbook to grab some values from a
cell. Once the active workbook grabs the data it needs it closes the other
workbook. The problem I have is the other workbook has some before close code
that prompts a user for an answer in messagebox form.

When I run my code from the activeworkbook I don't want this messagebox to
show up. Is there a way to make this happen. I tried the DiplayAlerts=False
but that did not work.

Thanks for your help.
Steve

Peter T

How to stop a msgbox pop up from another workbook
 
Hi Steve,

One way, in a normal module of the workbook that has the before close
message, set a global boolean, which if true flags the event code to not to
show the message. The flag would be set by a one line routine called by the
application.run method in the other wb.

Another way, temporarily disable EnableEvents

If neither the above are viable, just before you are about to close you
could try Sendkeys

Application.SendKeys ("{esc}")
wb.Close False

Regards,
Peter T

"Steve O" wrote in message
...
I have a workbook that opens another workbook to grab some values from a
cell. Once the active workbook grabs the data it needs it closes the other
workbook. The problem I have is the other workbook has some before close

code
that prompts a user for an answer in messagebox form.

When I run my code from the activeworkbook I don't want this messagebox to
show up. Is there a way to make this happen. I tried the

DiplayAlerts=False
but that did not work.

Thanks for your help.
Steve




Steve O

How to stop a msgbox pop up from another workbook
 
Thanks Peter! The EnableEvents method worked.

"Peter T" wrote:

Hi Steve,

One way, in a normal module of the workbook that has the before close
message, set a global boolean, which if true flags the event code to not to
show the message. The flag would be set by a one line routine called by the
application.run method in the other wb.

Another way, temporarily disable EnableEvents

If neither the above are viable, just before you are about to close you
could try Sendkeys

Application.SendKeys ("{esc}")
wb.Close False

Regards,
Peter T

"Steve O" wrote in message
...
I have a workbook that opens another workbook to grab some values from a
cell. Once the active workbook grabs the data it needs it closes the other
workbook. The problem I have is the other workbook has some before close

code
that prompts a user for an answer in messagebox form.

When I run my code from the activeworkbook I don't want this messagebox to
show up. Is there a way to make this happen. I tried the

DiplayAlerts=False
but that did not work.

Thanks for your help.
Steve






All times are GMT +1. The time now is 07:14 PM.

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