Search code examples
vbams-wordrichtext

Getting the 'content' from a Rich Text Content Control


I need to get the 'contents' of a Rich Text Content Control in Word, and paste that content into another Rich Text Content Control (formatted).

Here's the code I have:

ActiveDocument.SelectContentControlsByTitle("original").Item(1).Range.FormattedText.Copy
ActiveDocument.SelectContentControlsByTitle("duplicate").Item(1).Range.Paste

Which seems to work, but it's copying the entire original ContentControl into (nested) the duplicate ContentControl... and I just want the formatted text alone.

original and duplicate content which is nested

enter image description here


Solution

  • Try:

    With ActiveDocument
      .SelectContentControlsByTitle("duplicate")(1).Range.FormattedText = _
      .SelectContentControlsByTitle("original")(1).Range.FormattedText
    End With