Task Pane Demo Sample

Note

This sample runs only in Microsoft Office Word 2007.

This sample demonstrates how to create a custom task pane for Microsoft Office Word. The task pane contains a text box and a button. When the user types in the text box and clicks the button, the string in the text box is added to the beginning of the active document.

This sample automatically displays the task pane when the add-in loads. However, this sample does not provide a way for the user to display or hide the task pane. Typically, your add-in should provide a UI element, such as a button on the Ribbon, that users can click to display or hide your task pane. For a walkthrough that demonstrates how to do this, see Walkthrough: Synchronizing a Custom Task Pane with a Ribbon Button.

To create the custom task pane, this sample uses the CustomTaskPane and CustomTaskPaneCollection classes provided by Visual Studio Tools for Office. For more information about using these classes to create custom task panes, see Custom Task Panes Overview.

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 Contoso task pane, type some text in the text box.

  3. Click the Insert button.

    Verify that the text that you typed in the text box is inserted at the beginning of the active document.

Requirements

This sample requires the following applications:

  • Visual Studio Tools for Office.

  • Microsoft Office Word 2007.

Demonstrates

This sample demonstrates the following concepts:

  • Creating and displaying a custom task pane in a Word add-in.

  • Inserting text entered in the custom task pane into the active Word document.

See Also

Tasks

How to: Add a Custom Task Pane to an Application

Walkthrough: Automating an Application from a Custom Task Pane

Walkthrough: Synchronizing a Custom Task Pane with a Ribbon Button

Runtime Services Sample

Concepts

Custom Task Panes Overview

Customizing UI Features By Using Extensibility Interfaces

Other Resources

Document-Level Samples