Click here to Skip to main content
14,739,140 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a rich text box in my c# application and it contains different lines of text(one to many lines). I want to get those lines and insert it to a word document with the font and the font size i want. This is how it should look like.

OBSERVATIONS:
• Line 1 from the rich text box
• Line 2 from the rich text box
• Line 3 from the rich text box

i want this to happen by using interop library.
Posted

Use Microsoft Office and Word interop:

Create a solution. In the Solution Explorer tree view, select "References" node and use "Add Reference", the tab ".NET", choose "Microsoft.Office.Interop.Word" of appropriate version. Use one of these namespaces:
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word%28v=office.14%29.aspx[^],
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word%28v=office.11%29.aspx[^] (or the one per your version).

See MSDN help on this namespace and overview on Office and Excel programming:
http://msdn.microsoft.com/en-us/library/bb726434%28v=office.12%29.aspx[^].

—SA
   
Comments
VJ Reddy 27-Apr-12 22:53pm
   
Good guidance. 5!
Sergey Alexandrovich Kryukov 27-Apr-12 23:10pm
   
Thank you, VJ.
--SA
phantomlakshan 27-Apr-12 23:19pm
   
Can i have a bit of a code?
Sergey Alexandrovich Kryukov 30-Apr-12 19:36pm
   
Yes, you can, when you write it...

What kind of code? I don't know your detail. There are no lines in RTF, there are paragraphs, read them and insert in Word. There are thousands of code samples related to the API I referenced. Use some API members as keywords and search for the samples, but I would advise just to write your code moving toward your requirements instead of wasting time on samples...
--SA
I need some code guys. So i can test it and tweak it.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900