Data-Bound Content Controls Sample

Note

This sample runs only in Microsoft Office Word 2007.

This sample demonstrates how to bind content controls on a Word document to fields in a Microsoft Office Access database. Each content control on the document is bound to a different field in the Northwind sample database. The document also displays an actions pane that you can use to navigate through employee records, search for a specific employee record, and save changes that you make in one of the content controls to the database.

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.

    Verify that the content controls in the table display information about an employee named Nancy Davolio.

  2. In the actions pane, click the Next and Previous buttons to view different employee records.

    Verify that the content controls display information from the currently selected employee record.

  3. In the actions pane, enter a number from 1 through 9 in the Input ID text box, and click the Search by ID button.

    Verify that the content controls display information from the employee record that matches the ID.

  4. Click in the cell to the right of the Title cell and type a new title for the current employee.

  5. In the actions pane, click the Submit change to Title button to save the new title to the database.

  6. Open the Northwind.mdb database in Access, and verify that the Title field of the employee has the new title.

Requirements

This sample requires the following applications:

  • Visual Studio Tools for Office.

  • Microsoft Office Word 2007.

  • Microsoft Office Access.

  • The Northwind sample database for Microsoft Office Access (included in the sample).

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

Actions Pane Overview

Binding Data to Controls in Office Solutions

Other Resources

Document-Level Samples