Programmatically Open Word Document Located in the Computer in C#

后端 未结 3 2262
无人共我
无人共我 2021-02-20 07:59

I\'m using WinForms. I have a form that has a button.

Goal: On button click: Open up a word document. Where the file path is hard coded into the program. I don\'t want

3条回答
  •  灰色年华
    2021-02-20 08:18

    first add the dll of Microsoft.Office.Interop.Word to your references then add this:

    using Microsoft.Office.Interop.Word;
    

    and use the following code:

    Application ap = new Application(); 
    Document document = ap.Documents.Open(@"C:\Test\NewDocument.docx");
    

提交回复
热议问题