Load word file and html file into richtextbox

T

Twinkle

HI Guys
How to open a word file and HTML file (Without tags) into
richtextbox control.file is opening by this code but it is opening in
plaintext format but i want to open in word format

IDataObject Data1;
object nullobj,file;
WordApp=new Word.ApplicationClass();
nullobj=Missing.Value;
file =strFileName1;
WordDoc = 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);
WordDoc.ActiveWindow.Selection.WholeStory();
WordDoc.ActiveWindow.Selection.Copy();
Data1= Clipboard.GetDataObject();
str= Data1.GetData(DataFormats.StringFormat).ToString();
richTextBox2.Text = str;
Console.WriteLine(str);
WordDoc.Close(ref nullobj, ref nullobj, ref nullobj);

pla somebody help me.

Twinkle
 
G

Guest

Twinkle said:
How to open a word file and HTML file (Without tags) into
richtextbox control.file is opening by this code but it is opening in
plaintext format but i want to open in word format

I believe you need to make changes to the following lines in your code:

str= Data1.GetData(DataFormats.Rtf).ToString();
richTextBox2.Rtf = str;
 
T

Twinkle

Hi there
Thank you lot for help me
Twinkle


Mini-Tools Timm said:
I believe you need to make changes to the following lines in your code:

str= Data1.GetData(DataFormats.Rtf).ToString();
richTextBox2.Rtf = str;

--
Timm Martin
Mini-Tools
.NET Components and Windows Software
http://www.mini-tools.com
 

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