ClaudiaHelpOnVSTO

Hi,

How can I suppress MessageBoxes from appearing in Word 2003

Explanation of my scenario : A user clicks on a button in the document. A pop-up window (System.Windows.Forms.Form) is displayed which contains a WebBrowser control. After some time the user clicks on the red cross on the top right corner of the pop-up window to close the window and return to the Word document.

At this moment a new MessageBox is displayed with the following title : ¡°Microsoft Internet Explorer¡± and the following message ¡°The Web page you are viewing is trying to close the window. Do you want to close the window ¡±

Only having pressed twice the Yes button on the MessageBox, my form finally disappears!

Thanks for any hint!

Claudia



Re: Visual Studio Tools for Office Suppress MessageBox in Word

Douglas H. Troy

That error is an IE warning, not directly related to Word. Before you close out the window, make sure you assign the following

window.opener=this;

FYI - you'll have to get a reference to 'window' from your HTML through the Webbrowser control on your form, and then make the assignment mentioned above.

Here's an MSDN ref to what this is http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/opener.asp

That should keep that message box from displaying ...






Re: Visual Studio Tools for Office Suppress MessageBox in Word

Mike Walker

Douglas's answer is quite right, IE is raising the error as you are closing the IE window, Are you using the WebBrowser control in .NET2 or your own version, This is not really a VSTO Related question but I believe the answer is in this post.

Regards