title: While Opening Existing MS Word Document through VSTO Add-In Getting Exception, You cannot close Microsoft Word because a dialog box is open
body: <p>I've developed a VSTO Add-In. I've created a Ribbon, which makes a search button appearing into MS Word's Add-In tab. </p>
  
  <p>This Search button opens a Window which allows users to Search the Document from Cloud and Open/ Download the Same.</p>
  
  <p>I want to open the document being searched and downloaded from the cloud to be opened into existing MS Word Window.</p>
  
  <p><img src="https://i.stack.imgur.com/3e89Z.png" alt="User Interface Image"></p>
  
  <p>My Logic is:
  When selected document is downloaded by user. I'm copying it in the Local Directory and trying to open the same.</p>
  
  <p>Sample Code:</p>
  
  <pre><code>public void OpenDocument(string documentPath, Form form)  
  {
  
  _searchForm.Close();
  _searchForm.Dispose();
  
  
  Word.Document newDoc = Globals.ThisAddIn.Application.Documents.Open(documentPath);
  newDoc.Activate();
  
  }
  </code></pre>
  
  <p>But, I'm getting following exception.</p>
  
  <blockquote>
    <p>You cannot close Microsoft Word because a dialog box is open. Click OK, switch to Word, and then close the dialog box. </p>
  </blockquote>