Learn about content controls in Word and where to find them. Word for Office 365, Word 2019, Word 2016, Word 2013, Word 2010. Content controls are individual controls that you can add and customize for use in templates, forms,. Office 365: Adding Content Controls to Word Documents Open Word 2016. Switch to the File tab on the ribbon and click Options on the left. In the Options dialog box, click Customize Ribbon on the left. Make sure that Main Tabs is selected in the menu on the right below Customize the Ribbon.
A form in Word 2016 is a means of soliciting and recording information. You can use forms like the one shown to enter data faster and to reduce data-entry errors. Instead of entering all the information by hand, you or a data-entry clerk can choose entries from combo boxes, drop-down lists, and date pickers.
You save time because you don’t have to enter all the information by hand, and the information you enter is more likely to be accurate because you choose it from prescribed lists instead of entering it yourself.
To create a form like the one shown, start by creating a template for your form and putting data-entry controls — the combo boxes, drop-down lists, and date pickers — in the form. To fill out a form, you create a document from the form template and go to it. These pages explain how to create a form and use forms to record information.
Creating a computerized form
The first step in creating a data-entry form is to create a template for holding the form. After that, you design the form itself by labeling the data fields and creating the data-entry controls. Better keep reading.
Creating a template to hold the form
Follow these steps to create a new template:
- Press Ctrl+N to create a new document.
- On the File tab, choose Save As.You see the Save As window.
- Click the Browse button.The Save As dialog box opens.
- Open the Save As Type menu and choose Word Template.
- Enter a descriptive name for your template and click the Save button.Word stores your template in the Default Personal Templates Location folder.
Creating the form and data-entry controls
Your next task is to create the form and data-entry controls for your template. Enter labels on the form where you will enter information. The form shown earlier, for example, has five labels: Name, Phone, Fee Paid?, Association, and Date. After you enter the labels, follow these steps to create the data-entry controls:
- Display the Developer tab, if necessary.If this tab isn’t showing, go to the File tab, choose Options, and on the Customize Ribbon category of the Word Options dialog box, select the Developer check box and click OK.
- Click where you want to place a control, and then create the control by clicking a Controls button followed by the Properties button on the Developer tab.Here are instructions for creating three types of controls:
- Drop-down list: A drop-down list is a menu that “drops” when you open it to reveal different option choices. Click the Drop-Down List Content Control button and then the Properties button. You see the Content Control Properties dialog box, as shown here. For each option you want to place on the drop-down list, click the Add button, and in the Add Choice dialog box, enter the option’s name in the Display Name text box and click OK.Click the Add button to create options for a drop-down menu or combo box.
- Combo box: Like a drop-down list, a combo box “drops” to reveal choices. However, as well as choosing an option on the drop-down list, data-entry clerks can enter information in the box. Click the Combo Box Content Control button and then the Properties button. In the Content Control Properties dialog box, enter option names the same way you enter them in a drop-down list.
- Date picker: A date picker is a mini-calendar from which data-entry clerks can enter a date. Click the Date Picker Content Control button and then the Properties button. In the Content Control Properties dialog box, choose a display format for dates and click OK.
- Click the Save button to save your template.Now you’re ready to use your newly made form to enter data.
Entering data in the form
Now that you have the template, you or someone else can enter data cleanly in easy-to-read forms:
- On the File tab, choose New.You see the New window.
- Click the Personal tab.This tab lists templates stored on your computer.
- Double-click the name of the template you created for entering data in your form.The form appears.
- Enter information in the input fields.Press the up or down arrow, or press Tab and Shift+Tab to move from field to field. You can also click input fields to move the cursor there.
- When you’re done, print the document or save it.
This walkthrough demonstrates how to create a document-level customization that uses content controls to create structured and reusable content in a Microsoft Office Word template.
Applies to: The information in this topic applies to document-level projects for Word. For more information, see Features available by Office application and project type.
Word enables you to create a collection of reusable document parts, named building blocks. This walkthrough shows how to create two tables as building blocks. Each table contains several content controls that can hold different types of content, such as plain text or dates. One of the tables contains information about an employee, and the other table contains customer feedback.
After you create a document from the template, you can add either of the tables to the document by using several BuildingBlockGalleryContentControl objects, which display the available building blocks in the template.
This walkthrough illustrates the following tasks:
- Creating tables that contain content controls in a Word template at design time.
- Populating a combo box content control and a drop-down list content control programmatically.
- Preventing users from editing a specified table.
- Adding tables to the building block collection of a template.
- Creating a content control that displays the available building blocks in the template.NoteYour computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Personalize the IDE.
Prerequisites
You need the following components to complete this walkthrough:
- An edition of Visual Studio that includes the Microsoft Office developer tools. For more information, see Configure a computer to develop Office solutions.
- Microsoft Word.
Create a new Word template project
Create a Word template so that users can create their own copies easily.
To create a new Word template project
- Create a Word template project with the name MyBuildingBlockTemplate. In the wizard, create a new document in the solution. For more information, see How to: Create Office projects in Visual Studio.Visual Studio opens the new Word template in the designer and adds the MyBuildingBlockTemplate project to Solution Explorer.
Create the employee table
Create a table that contains four different types of content controls where the user can enter information about an employee.
To create the employee table
- In the Word template that is hosted in the Visual Studio designer, on the Ribbon, click the Insert tab.
- In the Tables group, click Table, and insert a table with two columns and four rows.
- Type text in the first column so that it resembles the following column:
Employee Name Hire Date Title Picture - Click in the first cell in the second column (next to Employee Name).
- On the Ribbon, click the Developer tab.NoteIf the Developer tab is not visible, you must first show it. For more information, see How to: Show the developer tab on the ribbon.
- In the Controls group, click the Text button to add a PlainTextContentControl to the first cell.
- Click the second cell in the second column (next to Hire Date).
- In the Controls group, click the Date Picker button to add a DatePickerContentControl to the second cell.
- Click the third cell in the second column (next to Title).
- In the Controls group, click the Combo Box button to add a ComboBoxContentControl to the third cell.
- Click the last cell in the second column (next to Picture).
- In the Controls group, click the Picture Content Control button to add a PictureContentControl to the last cell.
Create the customer feedback table
Create a table that contains three different types of content controls where the user can enter customer feedback information.
To create the customer feedback table
- In the Word template, click in the line after the employee table that you added earlier, and press Enter to add a new paragraph.
- On the Ribbon, click the Insert tab.
- In the Tables group, click Table, and insert a table with two columns and three rows.
- Type text in the first column so that it resembles the following column:
Customer Name Satisfaction Rating Comments - Click in the first cell of the second column (next to Customer Name).
- On the Ribbon, click the Developer tab.
- In the Controls group, click the Text button to add a PlainTextContentControl to the first cell.
- Click in the second cell of the second column (next to Satisfaction Rating).
- In the Controls group, click the Drop-Down List button to add a DropDownListContentControl to the second cell.
- Click in the last cell of the second column (next to Comments).
- In the Controls group, click the Rich Text button to add a RichTextContentControl to the last cell.
Populate the combo box and drop-down list programmatically
You can initialize content controls at design time by using the Properties window in Visual Studio. You can also initialize them at run time, which enables you to set their initial states dynamically. For this walkthrough, use code to populate the entries in the ComboBoxContentControl and DropDownListContentControl at run time so that you can see how these objects work.
To modify the UI of the content controls programmatically
- In Solution Explorer, right-click ThisDocument.cs or ThisDocument.vb, and then click View Code.
- Add the following code to the
ThisDocument
class. This code declares several objects that you will use later in this walkthrough. - Add the following code to the
ThisDocument_Startup
method of theThisDocument
class. This code adds entries to the ComboBoxContentControl and DropDownListContentControl in the tables, and sets the placeholder text that is displayed in each of these controls before the user edits them.
Prevent users from editing the employee table
Use the GroupContentControl object that you declared earlier to protect the employee table. After protecting the table, users can still edit the content controls in the table. However, they cannot edit text in the first column or modify the table in other ways, such as adding or deleting rows and columns. For more information about how to use a GroupContentControl to protect a part of a document, see Content controls.
To prevent users from editing the employee table
- Add the following code to the
ThisDocument_Startup
method of theThisDocument
class, after the code that you added in the previous step. This code prevents users from editing the employee table by putting the table inside the GroupContentControl object that you declared earlier.
Add the tables to the building block collection
Add the tables to a collection of document building blocks in the template so that users can insert the tables that you have created into the document. For more information about document building blocks, see Content controls.
To add the tables to the building blocks in the template
- Add the following code to the
ThisDocument_Startup
method of theThisDocument
class, after the code that you added in the previous step. This code adds new building blocks that contain the tables to the Microsoft.Office.Interop.Word.BuildingBlockEntries collection, which contains all the reusable building blocks in the template. The new building blocks are defined in a new category named Employee and Customer Information and are assigned the building block typeMicrosoft.Office.Interop.Word.WdBuildingBlockTypes.wdTypeCustom1
. - Add the following code to the
ThisDocument_Startup
method of theThisDocument
class, after the code that you added in the previous step. This code deletes the tables from the template. The tables are no longer necessary, because you have added them to the gallery of reusable building blocks in the template. The code first puts the document into design mode so that the protected employee table can be deleted.
Create a content control that displays the building blocks
Create a content control that provides access to the building blocks (that is, the tables) that you created earlier. Users can click this control to add the tables to the document.
To create a content control that displays the building blocks
- Add the following code to the
ThisDocument_Startup
method of theThisDocument
class, after the code that you added in the previous step. This code initializes the BuildingBlockGalleryContentControl object that you declared earlier. The BuildingBlockGalleryContentControl displays all building blocks that are defined in the category Employee and Customer Information and that have the building block typeMicrosoft.Office.Interop.Word.WdBuildingBlockTypes.wdTypeCustom1
.
Test the project
Users can click the building block gallery controls in the document to insert the employee table or the customer feedback table. Users can type or select responses in the content controls in both of the tables. Users can modify other parts of the customer feedback table, but they should not be able to modify other parts of the employee table.
To test the employee table
- Press F5 to run the project.
- Click Choose your first building block to display the first building block gallery content control.
- Click the drop-down arrow next to the Custom Gallery 1 heading in the control, and select Employee Table.
- Click in the cell to the right of the Employee Name cell and type a name.Verify that you can add only text to this cell. The PlainTextContentControl allows users to add only text, not other types of content such as art or a table.
- Click in the cell to the right of the Hire Date cell and select a date in the date picker.
- Click in the cell to the right of the Title cell and select one of the job titles in the combo box.Optionally, type the name of a job title that is not in the list. This is possible because the ComboBoxContentControl enables users to select from a list of entries or to type their own entries.
- Click the icon in the cell to the right of the Picture cell and browse to an image to display it.
- Try to add rows or columns to the table, and try to delete rows and columns from the table. Verify that you cannot modify the table. The GroupContentControl prevents you from making any modifications.
To test the customer feedback table
- Click Choose your second building block to display the second building block gallery content control.
- Click the drop-down arrow next to the Custom Gallery 1 heading in the control, and select Customer Table.
- Click in the cell to the right of the Customer Name cell and type a name.
- Click in the cell to the right of the Satisfaction Rating cell and select one of the available options.Verify that you cannot type your own entry. The DropDownListContentControl allows users only to select from a list of entries.
- Click in the cell to the right of the Comments cell and type some comments.Optionally, add some content other than text, such as art or an embedded table. This is possible because the RichTextContentControl enables users to add content other than text.
- Verify that you can add rows or columns to the table, and that you can delete rows and columns from the table. This is possible because you have not protected the table by putting it in a GroupContentControl.
- Close the template.
Next steps
You can learn more about how to use content controls from this topic:
- Bind content controls to pieces of XML, also named custom XML parts, that are embedded in a document. For more information, see Walkthrough: Bind content controls to custom XML parts.