Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Task Pane Demo Sample

Task Pane Demo Sample

Visual Studio 2008


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.

This sample requires the following applications:

  • Visual Studio Tools for Office.

  • Microsoft Office Word 2007.

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.

Community Additions

© 2015 Microsoft