Although it’s not necessary to have the content controls on the Word document to manipulate the documents using the Open XML SDK, it is always one of the best practices to have the documents with the content controls processed by the Open XML. It not only promotes the best practices for mutual agreement between word document template designer and Open XML programmer for systematic document manipulation but also provides great mechanism to identify the placeholder from the Open XML program to manipulate the contents with in word documents.
If you need to add the content controls on your word 2007 or word 2010 documents for Open XML automation, please follow below steps to design the document templates using the word content controls.
Step 1: Open the desired word document where you want to add the content controls. Please verify that Developer tab is available on the Ribbon toolbar. By default, developer tab is not enabled on the Office 2010 Ribbon Interface.
Step 2: If it’s not available then enable the Developer tab on the Ribbon toolbar from the options section. For the Word 2010, enable the developer tab from the Office Backspace.
Step 3: Once you have a developer tab, locate the specific section with in the document to add the content control. From the Developer tab, select the desirable content control from the Ribbon. Word 2010 supports seven content control types: Rich Text, Plain Text, Picture, Drop-Down List, Combo Box, Calendar, and Building Blocks. In this step by step process, we will add Rich Text Content Control by selecting the Rich Text Control from the Content Controls Groups area.
Step 4: Once you have added a content control, click Design Mode to set the design level properties of the content control. As you can notice, content control allows you to optionally change the content in the content control. For the Rich Text Area content control, you can add some pre-defined text or insert the table’s needs to be manipulated by the Open XML program.
Step 5: In the design mode, click on the “Properties” on the Developer Ribbon toolbar to set the properties of the content control. You can set the title of the content control, tag of the content control (tag will wrap the content in the control), and set the style to format the contents of the control. Additionally as a designer, you can set whether content within the control can be edited or content control can be deleted by the end user.
Step 6: After setting the properties, content control title and tag properties including contents within the control will be visible on the Design mode of the document.
Once you have word document template designed with the proper content controls, you can access the document from the Open XML program and locate the content control programmatically to manipulate the contents with in the content control.