Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get the RTF contents of a microsoft word document

Status
Not open for further replies.

swreng

MIS
Jun 22, 2006
90
GR
Dear all,

I would like to make a code which reads a word document and display the rtf contents in a richtextbox.

I wrote the following but i can't find how will i get the rtf data of the Document.

Is it possible or not?
The method:
Word.Document.Content.Text returns a plain text
Is there anything else about that?

Many thanks

object fileName = @"c:\test1.doc";
object readOnly = false;
object isVisible = true;
object missing = System.Reflection.Missing.Value;
object savechanges=false;
object originalformat=System.Reflection.Missing.Value;

Word.ApplicationClass oWordApp = new Word.ApplicationClass();

Word.Document oWordDoc = oWordApp.Documents.Open(ref fileName, ref missing,ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing,ref missing,ref missing, ref missing);


// The below Command is a plain Text even the document has tables
oWordDoc.Content.Text;
 
You could try saving the document to a temporary file as RTF, by setting the FileFormat parameter of <Document>.SaveAs to wdFormatRTF and then reading that file into your RichTextBox.


Hope this helps.

[vampire][bat]
 
Hi earthandfire,

I did it and it seems to working good but if the document is big it needs long time to read it. So i believed that there is a direct command do that and be more quickly, but even that it is a solution in my problem


Thanks a lot!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top