1
votes

Forgive me I'm lost and bewildered!

I have a document with several Plain Text Content Controls. So far, I can enumerate the SdtElements in the document , find all the SdtBlocks of interest and replace the text as needed ok.

Next though, I have one field in RichText format that I can retrieve from a database as a string and now need to insert this into the document. I've set up a Rich Text Content Control in the document but how do I set/replace this with the rich text string and retain the proper formatting?

Just to make me more confused, when I open the document with the "Word 2007 Content Control Toolkit" it shows all the Content Controls as expected and properly identifies the one as Rich Text type. When, however, I open the document using the "Open XML SDK 2.0 Productivity Tool" it shows the rich text control as a plain simple SdtBlock that appears completely indistinguishable from the plain text content controls and the reflected code seems identical?

How then to set the RichText string in the document?

1

1 Answers

0
votes

Plain text and rich text content controls are distinguished by a property in the content control's properties (w:sdt/w:sdtPr).

A rich text content control can contain WordML paragraphs and tables, or inline content, etc depending what level it is (block, inline, table row, table cell).

So you need to either convert your database content to appropriate WordML, or include an altChunk in the content control, and let Word do it for you.