Task Panes

A task pane at the document level is referred to as an a Actions Pane.
A task pane at the add-in level is referred to as a Task Pane.


Task Pane (Add-in Level)

Task panes are the interface panels typically docked to the right the the application.
MDI - single app frame, document windows inside - single task pane associated with app frame
SDI - each doc window in its own app frame - each doc window has its own task pane


Application20132010200720032002200097
ExcelSDIMDI
Show all windows in the taskbar
MDI
Show all windows in the taskbar
MDI
Windows in taskbar
MDI
Windows in taskbar
MDI
Windows in taskbar
MDI
WordSDISDI
Show all windows in the taskbar
SDI
Show all windows in the taskbar
SDI
Windows in taskbar
SDI
Windows in taskbar
SDI
Windows in taskbar
MDI
PowerPointSDISDIMDI
Show all windows in the taskbar
MDI
Windows in taskbar
MDI
Windows in taskbar
MDI
Windows in taskbar
MDI
Outlook       
InfoPath       

You can use the familiar windows forms designer to design your interface.
You can also use data binding support to bind a data sourece to the task pane controls.
All custom task panes are created contain a UserControl object (?)


Because the task pane is really just a toolbar you can access it through the CommandBars collection

Me.CommandBars("Task Pane").Position = msobarposition.msobarleft 


One difference between a custom task pane and a document level task pane is that you must explicitly set the Visible property to True to make the task pane visible.



UserControl control; 
control = new UserControl();
Microsoft.Office.Tools.CustomTaskPane pane;
pane = Microsoft.Office.Tools.CustomTaskPane.Add(control, "pane caption")

When a user closes a custom task pane, it still remains in memory until you remove it from the CustomTaskPanes collection.



The task pane is only visible in your original document.
To show document specific information you must track the currently active workbook and update the relevant information
This can be done using the Application.WindowActivate event.



When you close the document the visiblechanged event is fired and can be used to remove the task pane from the CustomTaskPanes collection.

private void ThisAddIn_Startup() 
{
   Microsoft.Office.Tools.CustomTaskPane pane = Globals.ThisAddIn.CustomTaskPanes.Add(new System.Window.Forms.UserControl(),
       "test title");
   pane.visible = true;
}


Events
DockPositionedChanged
VisibleChanged (if no active document, then remove all task panes)


mytaskpane += new System.EventHandler(TaskPane_VisibleChangedEvent) 

Application.WindowActivate activate


TaskPanes.ShowWindowsInTaskPane


Function GetTaskPaneForWindow() As Microsoft.Office.Tools.CustomTaskPane 
   For each pane in Globals.ThisAddIn.CustomTaskPanes
      If (pane.Window Is Globals.ThisAddin.Application.ActiveWindow)
         Return pane
      End If
   Next pane
End Function

Sub RemoveOrphanedTaskPanes
   For Each pane in Globals.ThisAddIn.CustomTaskPanes
      If (pane.window is nothing) and (pane.title = "") Then
         Globals.ThisAddIn.CustomTaskPanes.Remove(pane)
      End If
   Next pane
End Sub


Creating - VSTO


Add a WPF User Control
(Add > New Item)
Select "User Control (WPF) - UserControl1.xaml
Press Add


Add the following code to the startup class

private void ThisAddIn_Startup(object sender, System.EventArgs e) 
{
    System.Windows.Forms.UserControl WPF_WindowsUserControl;
    System.Windows.Forms.Integration.ElementHost _eh;

    _eh = new System.Windows.Forms.Integration.ElementHost { Dock = DockStyle.Fill, Child = new UserControl1() };

    WPF_WindowsUserControl = new System.Windows.Forms.UserControl();
    WPF_WindowsUserControl.Controls.Add(_eh);

    modSpecific._taskPane = Globals.ThisAddIn.CustomTaskPanes.Add(
        WPF_WindowsUserControl, "WJE Tools - Images");


    modSpecific._taskPane.VisibleChanged += _taskPane_VisibleChanged;
    modSpecific._taskPane.Width = 500;
    modSpecific._taskPane.DockPosition = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionRight;
    modSpecific._isTaskPaneVisible = false;

}



Creating - COM


link - https://theofficecontext.com/2013/05/21/customtaskpanes-in-a-net-shared-com-add-in/



Action Pane (Document Level)

Also known as the Document Actions task pane
You can create document action task panes for 2007 and later:
Using the VSTO ActionsPane object
available for Office 2003, Excel and Word from VSTO v2
available for Office 2007, Excel and Word from VSTO v2



ActionsPane.StackOrder
Microsoft.Office.Tools.StackStyle
Microsoft.VisualStudio.Tools.Applications.Runtime


Excel - Application.DisplayDocumentActionTaskPane
Word - Application.TaskPanes[wdTaskPanes.wdTaskPaneDocumentActions].Visible = True


ActionsPane.Hide - doesn't work
ActionsPane.Visible - doesn't work


The ActionsPane is actually a SmartDocument solution
ActionsPane.Clear - detach action pane from document
ActionsPane.Show - reattaches actionpane to document



The action pane is represented by the ActionsPane class
An instance of this class is available in both Excel and Word
In Excel - ThisWorkbook.ActionsPane (one per workbook)
In Word - ThisDocument.ActionsPane


Add windows forms controls to the Controls property of the ActionsPane fields


ActionsPane.Controls.Add (New MonthCalendar)
As soon as you add a control the task pane becomes visible immediately (by default).


Me.ActionsPane.Controls.Remove(mycontrol)

If Globals.ThisWorkbook.ActionsPane.Controls.Count < 1 Then 
   Application.CommandBars("Task Pane").Visible = False
End If

Display a built-in task pane

Application.TaskPanes(Word.wdTaskPanes.wdTaskPaneFormattng).Visible = True 

Me.CommandBars("Task Pane").Width = 150 

To detach the ActionsPane

Me.ActionsPane.Clear 


Outlook

Outlook handles custom task panes a bit different to the other applications.
Outlook might reuse a custom task pane that was associated with an Inspector previously
This can sometimes result in having multiple custom task panes for the same Inspector.
To avoid this you should explicitly remove all custom task panes when the Inspector is closed.

Outlook.Inspectors inspectors; 

private void ThisAddIn_Startup()
{
   inspectors = Application.Inspectors;
   inspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(event_NewInspector);
}

void event_NewInspector(Outlook.Inspector inspector)
{
   Microsoft.Office.Tools.CustomTaskPane pane = Globals.ThisAddIn.CustomTaskPanes.Add(new UserControl(),
                           System.DateTime.Now.ToLongTimeString(),
                           inspector);
   pane.visible = true;
   pane.visiblechanged += new EventHandler(pane_visiblechanged);

   //when you close an inspector, the visible changed event is not fired so use the Inspector_Close event
   ((Outlook..InspectorEvents_10_Event)inspector).Close += new Outlook.InspectorEvents_10_CloseEventHandler(event_InspectorClose);
}

void event_InspectorClose()
{
   Globals.ThisAddIn.CustomTaskPanes.Remove(pane);
   ((Outlook..InspectorEvents_10_Event)inspector).Close -= new Outlook.InspectorEvents_10_CloseEventHandler(event_InspectorClose);
   pane = null;
}



private void ThisAddIn_Startup(object sender, System.EventArgs e) { 
    // Initialize variables.
    m_Application = this.Application;
    m_Explorers = m_Application.Explorers;
    m_Inspectors = m_Application.Inspectors;
    m_Windows = new List<OutlookExplorer>();
    m_InspectorWindows = new List<OutlookInspector>();

    // Wire up event handlers to handle multiple Explorer windows.
    m_Explorers.NewExplorer +=
        new Outlook.ExplorersEvents_NewExplorerEventHandler(
            m_Explorers_NewExplorer);
    // Wire up event handler to handle multiple Inspector windows.
    m_Inspectors.NewInspector +=
        new Outlook.InspectorsEvents_NewInspectorEventHandler(
            m_Inspectors_NewInspector);
    // Add the ActiveExplorer to m_Windows.
    Outlook.Explorer expl = m_Application.ActiveExplorer()
        as Outlook.Explorer;
    OutlookExplorer window = new OutlookExplorer(expl);
    m_Windows.Add(window);

    // Hook up event handlers for window.
    window.Close += new EventHandler(WrappedWindow_Close);
    window.InvalidateControl += new EventHandler<
        OutlookExplorer.InvalidateEventArgs>(
        WrappedWindow_InvalidateControl);


void WrappedWindow_InvalidateControl(object sender,
    OutlookExplorer.InvalidateEventArgs e) {
    if (m_Ribbon != null)
    {
        m_Ribbon.InvalidateControl(e.ControlID);
    }
}


Microsoft.Office.Core.ICTPFactory.ICustomTaskPaneConsumer




© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext