I am trying to copy the contents of a word document which is basically in a letter format. I am trying to copy it onto a rich text box editor...but when i copy it..i am losing all the formatting of the word document.
This is the code i was using
Dim aDoc As Word.Document = WordApp.Documents.Open(outfile, missing, [readOnly], missing, missing, missing, missing, missing, missing, missing, missing, isVisible)
aDoc.ActiveWindow.Selection.WholeStory()
aDoc.ActiveWindow.Selection.CopyFormat()
Rte1.Text = aDoc.ActiveWindow.Selection.Text()
aDoc.Close()
WordApp.Application.Quit()
|
| Author: Hari 05 Nov 2009 | Member Level: Gold | Rating:  Points: 2 |
Hi, Try this.
Microsoft.Office.Interop.Word.Application wd = new Microsoft.Office.Interop.Word.Application(); object filename = @"c:\CuriculamVitae4job.doc"; object dummy = Missing.Value; wd.Documents.Open(ref filename, ref dummy, ref dummy, ref dummy, ref dummy, ref dummy, ref dummy, ref dummy, ref dummy, ref dummy, ref dummy, ref dummy, ref dummy, ref dummy, ref dummy, ref dummy); wd.Selection.WholeStory(); wd.Selection.Copy(); richTextBox1.Paste(); wd.Quit(ref dummy, ref dummy, ref dummy);
|
| Author: sasanka jonna 05 Nov 2009 | Member Level: Bronze | Rating:  Points: 2 |
did that work for you? If yes,what is this "richTextBox1" referring to? because the richtext control i am using doesnt have paste method. And by the way i am working on Web Application not a windows application.
If you know any rich text box for web application,please suggest.
|
| Author: Anil Kumar Pandey 06 Nov 2009 | Member Level: Diamond | Rating:  Points: 2 |
hi,
for that you need to save the doc file in .rtf format first..
open the .rtf file
read the content and then that can be pasted in the RTB.
Thanks & Regards Anil Kumar Pandey
|
| Author: Hari 06 Nov 2009 | Member Level: Gold | Rating:  Points: 2 |
Hi Sasanka,
My bad. Yes it is a windows application.
|