Content Controls Sample

Note

This sample runs only in Microsoft Office Word 2007.

This sample demonstrates how to use content controls on a Word document. The document includes a table that contains content controls in the second column, and brief descriptions for each content control in the first column. The sample also demonstrates how content controls can span page breaks.

Security noteSecurity Note:

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To run this sample

  1. Press F5.

  2. In the first row of the table, verify that you cannot edit or delete the rich text control.

  3. In the second row of the table, type a number in the plain text control.

    Verify that the control accepts only numbers from 1 through 100.

  4. In the third row of the table, click the icon in the picture control and browse to an image to display it.

  5. In the fourth row of the table, select one of the job titles or type your own job title in the combo box control.

    Verify that a warning appears if you click outside the combo box control without selecting or typing a title.

  6. In the fifth row of the table, select one of the levels in the list.

    Verify that the control does not accept values greater than 7 if the title Sales Representative is selected in the combo box control in the fourth row.

  7. In the sixth row of the table, select a date in the date picker control.

  8. In the last row of the table, type a street address, city, state, and zip code.

    Verify that you cannot delete any of the controls that are nested in the group control.

  9. In the rich text control after the table, insert a page break. Verify that the rich text control spans the page break.

Requirements

This sample requires the following applications:

  • Visual Studio Tools for Office.

  • Microsoft Office Word 2007.

Demonstrates

This sample demonstrates the following concepts:

See Also

Tasks

How to: Add Content Controls to Word Documents

How to: Protect Parts of Documents by Using Content Controls

Walkthrough: Creating a Template By Using Content Controls

Concepts

Content Controls

Other Resources

Document-Level Samples