How to stop a msgbox pop up from another workbook

S

Steve O

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
 
P

Peter T

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
 
S

Steve O

Thanks Peter! The EnableEvents method worked.

Peter T said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top