Fri
8
Feb '08
First refer COM objects - Microsoft Office xx.xx Object Libraryand Microsoft Word xx.xx Object Library
Here is the C# code for reading a word document:
Here is the C# code for reading a word document:
Microsoft.Office.Interop.Word.Application oWord = new Microsoft.Office.Interop.Word.Application();
object ofilename = @“C:\testdoc.doc”;
object o = System.Reflection.Missing.Value;
object oreadonly = true;
object ovisible = false;
Microsoft.Office.Interop.Word.Document oDoc = oWord.Documents.Open(ref ofilename, ref o, ref oreadonly
, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref ovisible, ref o, ref o, ref o, ref o);
textBox1.Text = oDoc.Content.Text; // contents available here
//Do not forget to quit other wize it will keep running in background
oDoc.Close(ref o, ref o, ref o);
oWord.Quit(ref o, ref o, ref o);

Leave a passing comment »