Step by Step: Add Content Controls in the Word Documents for the Open XML Automation

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.

About these ads
This entry was posted in Uncategorized. Bookmark the permalink.

8 Responses to Step by Step: Add Content Controls in the Word Documents for the Open XML Automation

  1. kmote00 says:

    Got stuck after Step 2. My content control buttons (on the Developer ribbon) are all disabled (greyed out). Any idea why that might be, or what I can do about it?

  2. junaidukaye says:

    Hi Nik, how do I mapp the text entered once in the form field to various location by changing only at one place. To be more precise: I want to enter client name once only in the document & map it various places in document without going to each place.

  3. When I protect the document, the tag and title go away. Is there a way to keep these for when someone goes to fill in the protected form they know what they are supposed to put?

  4. mareanoben says:

    Hi Nik,
    I tried using content control in Header area and selected header in the properties from style drop down box. I was copying fields from InfoPath to word (using Open XML), everything copied fine except the content control in the header area. Do you have any idea how to use content control in the Header area?
    Thanks.
    Ben

  5. Hi Nik,
    How do i hide the click ḧere to enter when printing or when am finished with the document ??

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s