Share via

Microsoft Word - find open dialogs

Anonymous
2023-06-14T08:53:02+00:00

If a dialog is open in 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).

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 not Windows and Dialog objects do not have a "state" and there does not appear to be a collection of open dialogs.

Does anyone know how to check for open dialogs?

Regards,

Charles

Microsoft 365 and Office | Word | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Anonymous
    2023-06-22T05:56:56+00:00

    Dear Charles,

    Thanks for your updates.

    Yes, you are right. An open dialog will prevent you from taking actions in Word. I'm afraid that there may be no out-of-the-box way helping you find the open dialog in Word. The easiest way to work around the issue may be to kill the process of Word in Task Manager and then relaunch Word again to move forward.

    Another way may be to use the development way Windows API FindWindowA function mentioned in FindWindowA function (winuser.h) - Win32 apps | Microsoft Learn to find the open diaglog. As the second way may need some code, I suggest you post a new thread on our specific support channel Windows Forms - Microsoft Q&A for further help to see if the members there will provide some code meeting your requirement.

    Here is a thread from that forum for your reference.

    Windows Forms - Microsoft Q&A

    Thanks for your understanding and have a nice day!

    Sincerely

    Cliff | Microsoft Community Moderator

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2023-06-14T09:38:54+00:00

    As far as I know any Dialog will cause the issue, eg with no document open we might have:

    Image

    Or with an open document (although we can work with the error handler solution if there is at least one document open):

    Image

    I'm working entirely with .docx files.

    I don't think Office version makes any difference, my PC has:

    Image

    Customers have various installed from Office 2016 to:

    You can get similar issue if you have a document open showing Properties Dialog and then try to print a document from Explorer without opening it - somehow Word displays a message box with:

    "Word can't do this because a dialog box is open. Please close the dialog box to continue."

    Thanks in advance.

    0 comments No comments
  3. Anonymous
    2023-06-14T09:17:52+00:00

    Dear Charles Waudby

    Good day to you. Thanks for querying in this forum.

    According to your description, we would like to collect more information with you:

    • Can you share a screenshot of the opened dialog to us?
    • Do all files have this behavior or only a specific one have?
    • Could you provide the Product Information and version of your Word? You can go to Word > File > Account and provide the screenshot of it. So we can test with the same version.

    Many thanks for your patience and understanding. Hope you are keeping safe and well.

    Sincerely,

    Stacey | Microsoft Community Moderator

    0 comments No comments