How to: Add an Actions Pane to Word Documents
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

How to: Add an Actions Pane to Word Documents

Note Required applications

The features in this topic are available only if you have the required applications installed.

For more information, see Features Available by Product Combination.

  • One of these development environments:

    VSTO 2005


    Visual Studio Team System

  • Microsoft Office 2003

The ActionsPane object is available to your Microsoft Visual Studio 2005 Tools for the Microsoft Office System projects, but is not visible until you add a Windows Forms control to it. You can program against events in the document to show and hide controls on the actions pane. You can also program against the events of the controls on the actions pane to perform actions within the document. For more information, see Walkthrough: Changing the Actions Pane According to User Context.

To add an actions pane to a Microsoft Office Word 2003 document, you can create a user control and then add it to the actions pane. The Add New Item dialog box contains an actions pane control that is a user control for the actions pane; you can use this control or a user control with equal results. For information on how to add an actions pane to a Microsoft Office Excel 2003 workbook, see How to: Add an Actions Pane to Excel Workbooks.


The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

Creating the Actions Pane Control

To create an actions pane control and insert text in the document

  1. Open your Word project in Visual Studio.

  2. On the Project menu, click Add New Item.

  3. In the Add New Item dialog box, select Actions Pane Control, name it HelloControl and click Add.

  4. If the actions pane control is not visible in the designer, double click HelloControl in the designer.

  5. From the Windows Forms tab of the Toolbox, select a Button control and drag it to the actions pane control.

  6. Add the following code to the Click event handler of the button.

    private void button1_Click(object sender, System.EventArgs e)
        Globals.ThisDocument.Paragraphs[1].Range.Text = "Hello World!";
  7. In C#, you must add an event handler for the button click. You can place this code in the HelloControl constructor after the call to IntializeComponent as shown below. For information on creating event handlers, see How to: Create Event Handlers in Visual Studio Tools for Office.

    public HelloControl()
        this.button1.Click += new EventHandler(this.button1_Click);

Adding the Actions Pane Control to the Actions Pane

In order to show the actions pane, you must first add a control to it. The following example adds an actions pane control to the actions pane in Word.

To add an actions pane control to the actions pane

  1. Create a new instance of the actions pane control in the ThisDocument class:

    private HelloControl hello = new HelloControl();
  2. Add the following code to the Startup event handler of ThisDocument:


See Also

© 2015 Microsoft