Home » Visual StudioRSS

Multiple Action Panes on different Worksheets


I like to create a projekt where on everey Worksheet a different Action Pane shows up. (e.g. for Navigation in a Workbook or task like printing etc.)

How can I do that?

I tried to hide the actionpanes in the sheet active Call but it didn't work. I only can show both actionpanes or none.

Or is there an other way to handle such problems ?

thanks a lot


6 Answers Found


Answer 1

Hi "hairpin"

Is this a workbook  project? Not an add-in?

In that case, there is only one ActionsPane available for the entire Workbook project. So I'm a bit confused when you write "both actionpanes".

Add-ins work  with Custom Task Panes, and you can define multiple  CTPs, but only for Add-ins.

While we're clearing that up, could you also tell us which version of Office and Visual Studio are involved, please?


Answer 2

Hi Cindy,

It's a Workbook Projekt and I'm working with VS 2010 and Office 2007.

I found this article:


and tried it the same way but the show  / hide  command fires on sheet  activate event.

I built 2 Action Pane Controls and I want to show only one of them depending on which Sheet I am. Maybe this is the reason for confusing. 1 Action Pane and 2 Action Pane Controls.

How can I handle  that ?



Answer 3

The basic logic you'll need to follow is similar to what is shown in that walkthrough: there is just one ActionsPane object available to your workbook  project, but you can add any number of UserControl objects to the ActionsPane (when you add an "Actions  pane  Control" item to your project, the generated ActionsPaneControl class is really just a Windows Forms UserControl). You can hide/show those UserControls as necessary. 

As you noted, the difference between that walkthrough and your scenario is that you need to tie the actions pane hide/show behavior with the SheetActivate event. The following code shows  one way you can do this. Add this code to your ThisWorkbook class, replacing the default ThisWorkbook_Startup event handler. This code assumes you have "Sheet1" and "Sheet2" worksheets  in your workbook, you have added two "Actions Pane Controls" items named "ActionsPaneControl1" and "ActionsPaneControl2".

internal ActionsPaneControl1 actionsPane1 = new ActionsPaneControl1();
internal ActionsPaneControl2 actionsPane2 = new ActionsPaneControl2();

private void ThisWorkbook_Startup(object sender, System.EventArgs e)
  this.Application.SheetActivate += new Excel.AppEvents_SheetActivateEventHandler(Application_SheetActivate);

  // Determine if we need to show  the actions pane for the initially active  sheet.

private void Application_SheetActivate(object Sh)

private void DisplayActionsPane(Excel.Worksheet sheet)
  switch (sheet.Name)
    case "Sheet1":
      Globals.ThisWorkbook.Application.DisplayDocumentActionTaskPane = true;
    case "Sheet2":
      Globals.ThisWorkbook.Application.DisplayDocumentActionTaskPane = true;
    // Show no actions pane for any other worksheet.
      Globals.ThisWorkbook.Application.DisplayDocumentActionTaskPane = false;

This posting is provided "AS IS" with no warranties, and confers no rights.


Answer 4

First thanks a lot,

do you have this code in vb.net ? :)




Answer 5

Try the following.

Dim actionsPane1 AsNew ActionsPaneControl1()
  Dim actionsPane2 AsNew ActionsPaneControl2()

  PrivateSub ThisWorkbook_Startup() HandlesMe.Startup

    ' Determine if we need to show  the actions pane  for the initially active  sheet.
    DisplayActionsPane(CType(Me.Application.ActiveSheet, Excel.Worksheet))
  EndSubPrivateSub ThisWorkbook_SheetActivate(ByVal Sh As System.Object) HandlesMe.SheetActivate
    DisplayActionsPane(CType(Sh, Excel.Worksheet))
  EndSubPrivateSub DisplayActionsPane(ByVal sheet  As Excel.Worksheet)
    Select sheet.Name
        Globals.ThisWorkbook.Application.DisplayDocumentActionTaskPane = True
        Globals.ThisWorkbook.Application.DisplayDocumentActionTaskPane = True
        ' Show no actions pane for any other worksheet.CaseElse
        Globals.ThisWorkbook.Application.DisplayDocumentActionTaskPane = FalseEndSelectEndSub

Answer 6


thank you so much works perfect !!!!!


<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter