locked
how to recover data from a word document RRS feed

  • Question

  • User838769528 posted

     Hi, somebody knows how to recover the data from a word document with a addin of VSTO I don't know what is the method..

    I'm working with Visual Studio Office tools and I have a Word 2003 project I have an addin button that launch a Windows form What I want to do is to recover the data of that instance and set it into a String,

    For example if the word document has this text:

    Hello, My name is blabla I want that text into a variable, this is going to happen when I press a button in the windows form.

    Thanx!

    Thursday, December 25, 2008 4:50 PM

Answers

  • User838769528 posted

     After search and search, I have found a solution:

    Word.Application app = Globals.ThisAddIn.Application;
    Word.Document doc = app.ActiveDocument;
    
    string a = doc.Content.Text;

     

    Note that you have to include "using Word = Microsoft.Office.Interop.Word;"

    So with this code above you can get all the content in a Word Document.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 26, 2008 4:27 AM