VSTO Excel solutions and disappearing Action Panes

If you are using Actions Panes in a VSTO Excel add-in you might have seen the following behavior. You create an new ActionPane, derived from UserControl, and add it to the Workbook ActionsPane.Controls collection. It shows up nicely so you think you are done.
Now the user creates a new Spreadsheet using File/New. Note that the ActionsPane disappears and remains hidden until the user reactivates it using View/Task Pane or Ctrl+F1.
So how do you automatically display the TaskPane when the user switched back to the original document? You need to add the following code to the ThisWorkbook type:
PrivateSub ThisWorkbook_WindowActivate(ByVal Wn As Window) HandlesMe.WindowActivate
    Application.DisplayDocumentActionTaskPane = True

2 thoughts on “VSTO Excel solutions and disappearing Action Panes

  1. Tnx, the C# code is:

    private void InternalStartup()
    this.WindowActivate += new Excel.WorkbookEvents_WindowActivateEventHandler(ThisWorkbook_WindowActivate);

    private void ThisWorkbook_WindowActivate(Excel.Window Wn)
    Application.DisplayDocumentActionTaskPane = true;

Leave a Reply

Your email address will not be published. Required fields are marked *