how to Read text from a word document using C#
CodeKeep C# Feed Giugno 25th, 2008
Description: how to Read text from a word document using C#Link: http://www.codekeep.net/snippets/42920bef-805c-4321-940b-26c9eb059de9.aspx
1>click Add reference to ur project select 'com' add reference for microsoftword
note: The name of your assemblies will vary based upon the version of Word that you have - in my case, it is version 11, or "Microsoft Word 11.0 Object Library."
2>For C# windows Application
-----------------------------
add namespace: using Word;
Code to get text from doc to textbox
-------------------------------------
openFileDialog1.ShowDialog();
string path = openFileDialog1.FileName.ToString();
Word.ApplicationClass wordApp = new ApplicationClass();
object file = path;
object nullobj = System.Reflection.Missing.Value;
Word.Document doc = wordApp.Documents.Open(ref file,ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj);
doc.ActiveWindow.Selection.WholeStory();
doc.ActiveWindow.Selection.Copy();
IDataObject data = Clipboard.GetDataObject();
txtload.Text = data.GetData(DataFormats.Text).ToString();