C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

Copying word document content to a rich text box without losing format


Posted Date: 05 Nov 2009      Posted By: sasanka jonna      Member Level: Bronze     Points: 1   Responses: 4



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()





Responses

Author: Hari    05 Nov 2009Member Level: GoldRating: 2 out of 52 out of 5     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 2009Member Level: BronzeRating: 2 out of 52 out of 5     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 2009Member Level: DiamondRating: 2 out of 52 out of 5     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 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

Hi Sasanka,

My bad. Yes it is a windows application.



Post Reply
You must Sign In to post a response.
Next : Reg : web service
Previous : Functions in SQL 2000
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use