none
Word not displaying when trying to open from winforms RRS feed

  • Question

  • Working on a winforms app (,NET 4.0, VS 2010, win 7) which will giev the user the ability to double-click a file name in a ListBox and open word.  These files live on a network drive.

    What I'm seeing is that WINWORD.EXE starts (in Task Manager), the "owner" file (i.e., ~$lename.doc) gets created on the network drive, but word never displays.  I neither get a window with the document in it, nor do I get a taskbar icon for word.  I do get the little pop-up that tells me it's downloading the file for a second or two (my test file is only 275K).

    I can navigate to the document and open it just fine.  That, combined with the fact that I get no exception, and my finally clause is hit, makes me think it's not a permission-based problem.


          Cursor myCursor = this.Cursor;
          try
          {
            this.Cursor = Cursors.WaitCursor;
    
            FileInfo selectedFile = ((List<FileInfo>)lbHomeStudyReports.DataSource)[lbHomeStudyReports.SelectedIndex];
            Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
            Microsoft.Office.Interop.Word.Document doc = app.Documents.Open(selectedFile.FullName);
            doc.Activate();
          }
          catch (Exception ex)
          {
            MessageBox.Show("An error has occurred trying to open the file: " + ex.Message, "Error");
          }
          finally
          {
            this.Cursor = myCursor;
          }
    • Edited by agolddog Monday, April 4, 2011 5:21 PM forgot code example
    Monday, April 4, 2011 5:20 PM

Answers

  • Maybe you need to make Word Visible - possibly something like

     

    app.Visible = true;

     

     


    Peter Jamieson
    • Marked as answer by Bruce Song Friday, April 22, 2011 5:45 AM
    Monday, April 4, 2011 5:37 PM

All replies

  • Maybe you need to make Word Visible - possibly something like

     

    app.Visible = true;

     

     


    Peter Jamieson
    • Marked as answer by Bruce Song Friday, April 22, 2011 5:45 AM
    Monday, April 4, 2011 5:37 PM
  • Hi Agolddog ,

     Have you resolved your issue yet, and does the suggestion help you?

    If you have any concern on the thread, feel free to follow up.

     Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, April 14, 2011 9:54 AM