Shayer said:
Thanks for ur advice
But how can i open the doc and read the content and display in the
richtextbox
How can u do that
ANy sample code will be helpful
Thanks
regards
Shayer
First of all add a reference to the word library. It should be located under
'COM' under 'Microsoft Word x.xx Object Library' (with x.xx your version).
Then the following code should do the trick :
/*************************************************/
object filename = @"c:\test.doc";
object save = false;
object oMissing = System.Reflection.Missing.Value;
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = false;
// Open word document
// different versions of word may have more or less oMissings
oDoc = oWord.Documents.Open(ref filename, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing);
// Select everything
oDoc.Select();
// Copy everything
oWord.Selection.Copy();
// Clean up the RTB
richTextBox1.Text = "";
// Paste the entire text with format
richTextBox1.Paste();
// Close word
oDoc.Close(ref save, ref oMissing, ref oMissing);
oWord.Quit(ref save, ref oMissing, ref oMissing);
/*************************************************/
HTH
Yves