Last post Dec 26, 2008 04:27 AM by javito
Dec 25, 2008 04:50 PM|javito|LINK
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.
Dec 26, 2008 04:27 AM|javito|LINK
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.