How to read a word document's content ?

V

vincent

Many thanks for your replying.

try
{
// Declaring the object variables we will need later
object varFileName = "c:\\test\\sample.doc";
object varFalseValue = false;
object varTrueValue = true;
object varMissing = Type.Missing;
// Create a reference to MS Word application
Microsoft.Office.Interop.Word.Application varWord = new
Microsoft.Office.Interop.Word.Application();

// Creates a reference to a word document
Microsoft.Office.Interop.Word.Document varDoc =
varWord.Documents.Open(ref varFileName, ref varMissing, ref varFalseValue,
ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref
varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing,
ref varMissing, ref varMissing, ref varMissing, ref varMissing);
// Activate the document
varDoc.Activate();

//Please add code here


//CLOSING THE FILE
varDoc.Close(ref varFalseValue, ref varMissing, ref
varMissing);
//QUITTING THE APPLICATION
varWord.Quit(ref varMissing, ref varMissing, ref varMissing);
}
catch (Exception exception)
{
MessageBox.Show(exception.ToString());
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top