0

I have a Solution that has a windows forms project in it. I have added a Word Document to it so that I could use this for a reporting tool. It seems that I have run into some problems while trying to open this.

I found this, which helped me out a lot but now when I try to use the code below, I'm getting an error message that tells me "ThisDocument does not contain a constructor that take 0 arguments."

        wrd.Application wrdApp = new wrd.Application();
        ThisDocument doc = new ThisDocument();

So I look at the tool tips and they say "Mircosoft.Office.Tools.Word.Factory, IServiceProvider". Can someone explain what these are?

Community
  • 1
  • 1
3xGuy
  • 2,235
  • 2
  • 29
  • 51
  • According to MSDN (https://msdn.microsoft.com/en-us/library/aa189914%28v=office.10%29.aspx) that class is deprecated, consider trying a more up-to-date word interop. – BradleyDotNET May 20 '15 at 17:52
  • 1
    Bradley, your link is to the Visio ThisDocument object, not the Word interop version. – maniak1982 May 20 '15 at 17:56
  • How would I reference this to open it then? – 3xGuy May 20 '15 at 17:58
  • You should not have a reference to Microsoft.Office.Tools.Word, that is only appropriate when you write an add-in for Word. Did you use the wrong project template? – Hans Passant May 20 '15 at 17:58
  • I Chose Word 2013 Document. this isn't an add-in. – 3xGuy May 20 '15 at 18:00
  • ThisDocument refers to the current document. It isn't used as a constructor but is used instead of an explicitly declared Document object, as explained in this MSDN page: https://msdn.microsoft.com/en-us/library/office/aa192495%28v=office.11%29.aspx – maniak1982 May 20 '15 at 18:01
  • thank you for this, bit it seems that I still cannot get this to open. So lets say this document, is Named wrd1 How can I open it? – 3xGuy May 25 '15 at 14:27

0 Answers0