Reading Rich Text into Microsoft Office 2007 using VSTO

I am developing C#.Net application in which Rich Text is created in one of several several Rich Text Edit boxes in the application. I am also using Visual Studio Tools for Office in order to Programmatically add the Rich Text content into a Microsoft Office document in various locations.  My problem is that I have not been able to get the Rich Text read in preserving the formatting.  I have tried using a ContentControl and setting the Type = WdContentControlType.wdContentControlRichText, but the Word Document only interprets it as raw text.  Should I be using some other technique?

I'm really not even sure how to read text into the ContentControl.  I have tried using a Range, but maybe that's not the correct way.

I am using C#.Net with Visual Studio 2008 and Microsoft.Office.Core and Microsoft.Office.Interop.Word.
Who is Participating?
You could take a look at the following MS KB - which describes how to create an RTF string, copy the RTF string to the clipboard, and then paste the RTF string into the document.  You could convert the VB code that is there into C# and modify it so that the text is copied into the content control rather than the Word document itself.
thomehmAuthor Commented:
I am using the Clipboard to insert the Rich Text, my code is a little simpler and different:

                    Clipboard.SetData(DataFormats.Rtf, strDescription);
                    RowCurrent.Cells[defs.ICIName + 1].Range.Paste();

It seems to work for me.
Glad to hear that you came up with something that worked...thanks for posting the code (I agree, your code is much simpler)!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.