Create Office 2019 - 2007 custom task panes
in VB.NET, C#, C++
Add-in Express Home > Add-in Express for Office and .NET > Online Guide > Add-in Express components > Custom Office task panes
Custom task panes in Office 2019 - 2007
To allow further customization of Office applications, Microsoft introduced custom task panes in Office 2007 and supported them further in Office 2010, 2013, 2016 and 2019. Add-in Express allows you to create Office custom task panes by equipping the COM Add-in module with the TaskPanes property. Add a UserControl to your project, add an item to the TaskPanes collection of the add-in module, and set up the item by choosing the control in the ControlProgId property and filling in the Title property. Add your reaction to the OnTaskPaneXXX event series of the add-in module and the DockPositionStateChange and VisibleStateChange events of the task pane item. Use the OfficeColorSchemeChanged event and the OfficeColorScheme property to get the current Office color scheme.
Below is the detailed description of how to create a custom task pane with Add-in Express.
To add a new task pane, you add a UserControl to your project and populate it with controls. Then you add an item to the TaskPanes collection of the add-in module and specify its properties:
In Add-in Express, you work with the task pane component and task pane instances. The TaskPanes collection of the add-in module contains task pane components. When you set, say, the height or dock position of the component, these properties apply to every task pane instance that the host application shows. To modify a property of a task pane instance, you should get the instance itself. This can be done through the Item property of the component (in C#, this property is the indexer for the ADXTaskPane class); the property accepts a window object (such as Outlook.Explorer, Outlook.Inspector, Word.Window, etc) as a parameter and returns an AddinExpress.MSO.ADXTaskPane.ADXCustomTaskPaneInstance representing a task pane instance. For instance, the method below finds the currently active instance of the task pane in Outlook and refreshes it. For the task pane to be refreshed in a consistent manner, this method should be called in appropriate event handlers.
The InfoString property just gets or sets the text of the Label located on UserControl1. The GetSubject method is shown below.
The code of the GetSubject method emphasizes the following:
Below is another sample that demonstrates how the same things can be done in Excel or Word 2019, 2016, 2013, 2010 and 2007.
The InfoString property mentioned above just updates the text of the label located on the UserControl. Please pay attention to Releasing COM objects in this code.