Pieter van der Westhuizen

Building custom task panes for Word 2013 – 2003

Task panes provide a great way to deliver a custom user interface inside Microsoft Word if the standard ribbon bar simply does not suffice. It gives you the opportunity to display a fairly large amount of information to the user as well as giving the user the option to hide or show it at their choosing.

When building a Word add-in using Add-in Express, you have a choice of either creating a standard Office task pane or using the Add-in Express advanced Office task panes. In this article, we’ll take a look at both approaches.

Creating a Word COM add-in project

Start by creating a new ADX COM Add-in project in Visual Studio. You’ll find the project template under Other Project Types > Extensibility

Creating a new Word COM add-in project

The project template will initiate the New Microsoft Office COM Add-in wizard. When prompted, select your programming language of choice (C#, VB.NET or C++.NET), the minimum supported version of Office (2000 – 2013) you would like the add-in to support as well as in which Office applications you want it to work.

Since we’ll be focusing on Microsoft Word for this article, we’ll only select Word from the list of supported applications.

Selecting the programming language, minimum supported version of Office and targeted application

Building a standard Word task pane

The standard Word Task pane looks and operates exactly like the normal Word task panes. You can drag and drop it to one of four (top, bottom, left, right) locations within the Word main window and it cannot be minimized, only closed. The standard custom task panes support Word 2007, 2010 and 2013.

To create your own custom task pane, first add a new User Control to your project, by selecting Add User Control… from the Visual Studio Project menu.

Adding a new User Control to the project

You can then design the user interface for the task pane as you would any standard windows form. In this scenario, we’re building a simple word counter.

The custom task pane's design

Next, switch to the AddinModule designer surface and click on the ellipses (…) button next to its TaskPanes property in the Visual Studio properties window.

Adding the task pane item to the TaskPanes collection

You will be presented with the TaskPane Collection Editor. Click on the Add button to add a new item to the collection and set the following properties:

  • ControlProgID : WordTaskPanes.ctlTaskPane (The name of the User control we’ve added earlier)
  • DockPosition : ctpDockPositionRight
  • DockPositionRestrict : ctpDockPositionRestrictNone
  • SupportedApps : Word
  • Title : Word Counter

Configuring the custom task pane's properties

Build, register and run your Word addin project. You should see the custom task pane docked to the right of the Word application window.

The standard Office task pane docked to the right of the Word application window

Creating an advanced Word task pane

Add-in Express’ advanced Word task panes give you the functionality of the standard task panes, but with the added options of (a) minimizing the task pane, as well as (b) to host more than one task pane per dock location. Advanced task panes support all versions of Microsoft Word, from 2000 through Word 2013.

Before we can create an advance task pane, we need to add an ADXWordTaskPanesManager component to the AddinModule designer surface.

Adding a Word Task Panes Manager component to the AddinModule designer surface

Next, add a new ADX Word Task Pane to the project. You can find the item template under Add-in Express Items > Word

Adding an advanced Task Pane to the Word add-in project

You can design the advanced Word Task pane similarly to what was done with the standard user control. When you’re satisfied with the design, switch back to the AddinModule designer surface and select the ADXWordTaskPanesManager component we’ve added earlier.

On the built-in Visual designer toolbar, click the Add button. This will add a new item to the Task Panes Manager’s Items collection.

The ADXWordTaskPanesManager component is added to the Items collection of the Task Panes Manager

Select the item in the visual designer and change the following properties:

  • AllowedDropPositions : Bottom;Left;Right;Top
  • AlwaysShowHeader : True
  • IsDragDropAllowed : True
  • Position : Left
  • TaskPaneClassName : WordTaskPanes.ADXWordTaskPane (The name of the Advanced task pane we’ve added earlier)

Before we run the add-in to see our advanced task pane in action, add another ADX Word Task Pane item to the project and select the ADX Word Task Panes manager on the AddinModule designer surface.

Add another item to its Items collection and this time set its TaskPaneClassName property the newly added Task Pane’s name and also set its Position property to Left.

This will:

a) Cause both the advance task panes to be docked to the left of the Word application window.

b) Automatically show two arrow icons, with which the user can switch between different task panes.

c) Show a drop-down menu listing of all the available task panes.

Two advanced task panes in Word 2013

Advanced task pane and standard Office task pane co-existence

In case you were wondering. Yes, you can have both a standard Office task pane and an Add-in Express advance task pane in the same Word add-in and they will both co-exist in prefect harmony. In the following example, I have the standard task pane docked to the right and the advance task pane docked to the left of the Word 2013 application window:

The advanced task pane and standard Office task pane in Word 2013

Thank you for reading. Until next time, keep coding!

Word add-in development in Visual Studio for beginners:

One Comment

  • Andreas Waning says:

    Your post in Facebook are very helpfull.
    I have AddinExpress and have Problems to find samples. Now the Posts in Facebook is that what i also search….
    Thanks,
    Andreas

Post a comment

Have any questions? Ask us right now!