How to get formatted text content inside a RichTextContentControl RRS feed

  • Question

  • Hi,

    I'm trying to get the content for a RichTextContentControl (inside Exiting event handler) to copy to the clipboard (to paste on another CC as formatted text). The problem comes when trying to copy the control range, because it copies the control itself also:

    private void CodeCtrl_Exiting_RichText(object sender, Microsoft.Office.Tools.Word.ContentControlExitingEventArgs e)
        Microsoft.Office.Tools.Word.RichTextContentControl ctrl = sender as Microsoft.Office.Tools.Word.RichTextContentControl;
        string strRTF = "";

        //ctrl.Range.Copy(); // not working
        //ctrl.Range.FormattedText.Copy(); // not working

        if (Clipboard.ContainsText(TextDataFormat.Rtf))
            strRTF = Clipboard.GetText(TextDataFormat.Rtf);


    Any idea on how to copy only the formatted text contained inside the control (without the control itself)?

    Kind regards

    Wednesday, October 26, 2016 9:51 PM

All replies

  • Hi,

    Please visit Range.FormattedText property, the property is in Microsoft.Office.Interop.Word, so we could successfully copy the formatted text using like the following:

                Microsoft.Office.Interop.Word.ContentControl rtc = Globals.ThisAddIn.Application.ActiveDocument.SelectContentControlsByTitle("test")[1];




    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Thursday, October 27, 2016 6:01 AM