Word built-in dialogs

Add-in Express™ Support Service
That's what is more important than anything else

Word built-in dialogs
 
David Canek


Guest


Hi,

this is more Word automation than ADX related question. From my experience with a Word ADX add-in, it seems that executing any code while a Word built-in dialog (e.g., Find dialog) is displayed is not a good idea. Do you know if it is possible to check that a Word built-in dialog is displayed?
Posted 04 May, 2011 10:01:59 Top
Eugene Astafiev


Guest


Hi David,

Please try to use the ActiveWindow property of the Application and Document class in Word. Does it help?
Posted 04 May, 2011 10:58:25 Top
David Canek


Guest


Thanks for the hint. Unfortunately, ActiveWindow always returns the underlying document window. Document.Windows.Count returns 1 even if the Find dialog is displayed. Do you any other idea?

Actually, I am trying to solve this issue. The add-in listens to the WindowSelectionChange event and whenever it occurs, the add-in reads the current selection (and some other parts of the document). It works perfectly until the Find dialog is used. When a string is found by the Find dialog, the WindowSelectionChange event is fired and the handler sometimes (very randomly) cause the Find dialog to disappear which is very frustrating for users.
Posted 05 May, 2011 02:38:23 Top
Eugene Astafiev


Guest


Hi David,

Please try using some WinAPI functions to find the "Find" dialog window in that case.
Posted 05 May, 2011 02:57:25 Top
David Canek


Guest


Thanks Eugene,

I have used GetForegroundWindow, GetWindowText, and some other WinAPI functions to check whether the Word Find dialog is opened or not. It's an ugly code (compared to calling Word API) but it works.
Posted 06 May, 2011 07:18:03 Top
Eugene Astafiev


Guest


Hi David,

Good news! Thank you for letting me know.
Posted 06 May, 2011 07:26:51 Top