none
Word process crashes on open without being able to be catch the exception. RRS feed

  • Question

  • My code:

    Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
                
    Microsoft.Office.Interop.Word.Document doc = null;

    try {

      word.Visible = true;

      object inputFile = d.FullName + "\\" + dao.Template;

      doc = word.Documents.Open(ref inputFile, ReadOnly: false, Visible: true, OpenAndRepair: true);

    } catch (Exception e) {

      ...

    }

    Opening word documents created on my local PC work fine. Whenever I open a word document that has been created or modified on another PC, the open method crashes and the surrounding try catch doesn't get called.

    Any help highly appreciated. Thanks


    • Edited by slang2310 Thursday, March 2, 2017 10:35 AM forgot catch
    Thursday, March 2, 2017 10:18 AM

All replies

  • Hi Ronnie,

    According to your issue, I’d like to confirm the following with you which could be helpful to provide the suitable suggestions.

    >>Opening word documents created on my local PC work fine. Whenever I open a word document that has been created or modified on another PC....

    What's the meaning of being created/modified on anothe PC,do you try to open a document at a Shared folder or a document copied from another PC?

    In order to provide a solution to your issue effectively, I’m wondering if you could provide more details, for instance, what's d.FullName and dao.Template.

    Looking forward to your reply.

    Best regards,

    Terry


    Friday, March 3, 2017 7:07 AM
  • Hello,

    The Open method accepts a local file path. You need to copy the file to the hard drive first.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Monday, March 27, 2017 8:02 PM