Microsoft Word - find open dialogs #58362
Unanswered
CharlesWaudby
asked this question in
Programming Help
Replies: 2 comments
-
Another approach you could try is checking for active windows outside of Word itself using the Windows API. It’s a bit more complex, but it can help identify when a dialog is open, even if it’s not directly accessible through Word’s object model. For anyone dealing with Word’s quirks often, having a good selection of Microsoft products and tools can help streamline your workflow and avoid these kinds of headaches. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Body
If a Dialog is open in Microsoft Word then certain methods will fail, example below. We can get round this if there is a document open wrapping the call into an error handler but if no documents are open this cannot be done (I don't want to randomly open a temporary new document to test because if a Dialog is open we cannot close the new document it for the same reason).
One example:-
Microsoft.Office.Interop.Word.WdProtectionType ProtectionType = document.ProtectionType;
This is a problem because we do not want to open a document if we cannot control things like ProtectionType (these are confidential clinical documents so control is critical).
Dialogs are Windows but Dialog objects do not have a "state" and there does not appear to be a collection of open dialogs.
Finding open Dialogs from Window handles is ?impossible as the parent handle of a Dialog window is the Desktop (I was surprised). (Short of maintaing a list of all Dialog Window Titles and hoping they are unique - which they are not, eg "Save As" - I have not found any clues.
Does anyone know if there is any way to check for open Dialogs?
Regards,
Charles
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions