How to: Add an Actions Pane to Excel Workbooks

Applies to

The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office.

Project type

  • Document-level projects

Microsoft Office version

  • Excel 2007

  • Excel 2003

For more information, see Features Available by Application and Project Type.

The ActionsPane object is available to your Visual Studio Tools for Office projects, but it is not visible until you add a Windows Forms control to it.

To add an actions pane to a Microsoft Office Excel workbook, 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.

Note

You can create an actions pane only in a document-level customization for Word or Excel. You cannot create an actions pane in an application-level add-in. For more information, see Features Available by Application and Project Type.

Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

link to video For a related video demonstration, see How Do I: Use WPF Controls Inside an Excel Actions Pane?.

Creating the Actions Pane Control

To add an actions pane control to your project

  1. Open your Excel workbook or template 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.

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

  4. From the Windows Forms tab of the Toolbox, drag a Button control to the actions pane control.

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

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles Button1.Click
    
        Globals.Sheet1.Range("A1").Value2 = "Hello world!" 
    End Sub
    
    private void button1_Click(object sender, System.EventArgs e)
    {
        Globals.Sheet1.Range["A1", System.Type.Missing].Value2 = "Hello World!";
    }
    
  6. In C#, you must create an event handler for the Button. You can place this code in the HelloControl constructor. For more information about creating event handlers, see How to: Create Event Handlers in Visual Studio Tools for Office.

    public HelloControl()
    {
        InitializeComponent();
        this.button1.Click += new System.EventHandler(this.button1_Click);
    }
    

Adding the Actions Pane Control to the Actions Pane

To show the actions pane, you add controls to it.

To add an actions pane control to the actions pane

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

    Dim hello As New HelloControl
    
    private HelloControl hello = new HelloControl();
    
  2. Add the following code to the Startup event handler of ThisWorkbook.

    Me.ActionsPane.Controls.Add(hello)
    
    this.ActionsPane.Controls.Add(hello);
    

See Also

Tasks

Walkthrough: Inserting Text into a Document from an Actions Pane

How to: Add an Actions Pane to Word Documents

Walkthrough: Changing the Actions Pane According to User Context

How to: Manage Control Layout on Actions Panes

Concepts

Actions Pane Overview

Other Resources

How Do I: Use WPF Controls Inside an Excel Actions Pane?