How to CLOSE ALL DIALOGS before saving???

A

Antinsh

That's it! I need to save my file from code but if someone has opened like
say FIND DIALOG then you cant save. So I would like to know if there's any
way to close all the open dialogs before saving.

Dont be shy:) Any help will be appreciated.
 
F

fumei via OfficeKB.com

Hmmm. No reply yet. I would be interested in someone came up with something.
I am not sure it is possible. An open dialog has focus. You can not execute
anything until it loses that focus.

If you have any open dialog, and try to run any code at all, even right from
the VBE, you can't. The Application object is giving full focus to the
dialog.

I would be happy to hear that one could do what you are asking, but it may
not be possible.
 
J

Julian

I can't see what the original question was but reading between the lines...
and assuming this is Word VBA...

fumei via OfficeKB.com said:
Hmmm. No reply yet. I would be interested in someone came up with
something.
I am not sure it is possible. An open dialog has focus. You can not
execute
anything until it loses that focus.

If you have any open dialog, and try to run any code at all, even right
from
the VBE, you can't. The Application object is giving full focus to the
dialog.

In principle IF the dialog is MODAL, not otherwise - but I regularly see
supposedly MODAL dialogs that have lost focus and can't easily be dismissed.
And OnTime code will run whenever it's supposed to except in Debug mode -
and the VBE will tell you that it has failed to run as soon as it tries.

To get rid of potentially lurking dialogs - if they are userforms, msgbox's,
inputs - enforce some form of titling convention and then iterate through
the Tasks collection and close the task on string matching - but beware:
unpredictable results may occur, but it's handy if you're stuck... you can
even do it across applications via the Tasks collection.
 

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