What is the Actions Pane?
Ever since the task pane was introduced in Microsoft Office XP for the first time, Office solution developers have asked, "How can I create my own version of a task pane to use as part of my Office solutions?" (If you're not sure what the task pane is, click Task Pane on the View menu in an application such as the XP or 2003 versions of Microsoft Office Excel or Microsoft Office Word.)
Starting with Microsoft Office 2003, you can create your own version of the task pane. More specifically, you can enable your end users and Excel workbooks or Word documents to interact with the built-in Document Actions task pane, whose layout you can modify. We call this type of Office solution a smart document solution. (It’s true that there are other types of smart document solutions that don't rely on customized task panes, but the task pane is used in almost all smart document solutions out there.)
Microsoft Visual Studio Tools for the Microsoft Office System, Version 2.0 extends and improves the smart document solution development infrastructure for Excel and Word. We use the term actions pane to differentiate the a Visual Studio Tools for Office, Version 2.0 solution that uses the Document Actions task pane from its built-in Office counterpart, a smart document solution. How does the actions pane extend and improve on smart documents?
- With the actions pane, Excel workbooks and Word documents can be based on XML, but they don't have to be.
- You write code using an ActionsPane object that is very comfortable to you as a .NET developer. You can reference the actions pane with just a few lines of code.
- You can use any .NET user interface control in the actions pane, or you can create your own .NET UserControls.
- You don't have to worry about creating an XML expansion pack, which means you don't have to worry about digitally signing it either. End users don't have to worry about working with the non-intuitive XML Expansion Packs dialog options and settings either.
Here's how easy it is to create an actions pane in a Visual Studio Tools for Office, Version 2.0 project.
First, create an Excel Application, choosing either the Visual Basic or C# language. After the project is created, create two .NET UserControls and keep their default control names, UserControl1 and UserControl2. (To create a UserControl and add it to the current project, on the Project menu, click Add UserControl, and click Add.) To ensure that you can see the UserControls when you run the project, you may want to add a label control, a text box control, and a button control to each user control with some default display text.
Next, in the ThisWorkbook code module, create an instance of each UserControl just prior to the ThisWorkbook_Initialize event.
' Visual Basic
Dim uc1 As UserControl1
Dim uc2 As UserControl2
// C#
UserControl1 uc1;
UserControl2 uc2;
Next, initialize the UserControls inside of the ThisWorkbook_Initialize event.
' Visual Basic
uc1 = New UserControl1()
uc2 = New UserControl2()
// C#
uc1 = new UserControl1();
uc2 = new UserControl2();
Next, display each UserControl on the actions pane inside of the ThisWorkbook_Initialize event.
' Visual Basic
Me.ActionsPane.Controls.Add(uc1)
Me.ActionsPane.Controls.Add(uc2)
// C#
this.ActionsPane.Controls.Add(uc1);
this.ActionsPane.Controls.Add(uc2);
Whenever you want to hide a UserControl (for example, when an end user moves focus to a different named range), call the Remove method.
' Visual Basic
Me.ActionsPane.Controls.Remove(uc1)
// C#
this.ActionsPane.Controls.Remove(uc1);
Similarly, whenever you want to show a UserControl, call the Add method again.
' Visual Basic
Me.ActionsPane.Controls.Add(uc1)
// C#
this.ActionsPane.Controls.Add(uc1);
And that's it!
In future blog posts, I will show you how to build upon this simple example by writing code that allows UserControls on the actions pane to interact with the document, and vice versa.
-- Paul Cornell
-----
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at https://www.microsoft.com/info/cpyright.htm.
Comments
Anonymous
March 13, 2004
That was the question ... I was recently asked by a colleague. Are there any advantages to creating our smart document solutions using Visual Studio Tools for Office 1.0 rather than just .NET 2003? While the answer is a resounding...Anonymous
June 23, 2004
Paul,
I have read a couple of your blogs, they have been very useful, thanks.
Is it possible to change the name displayed for the Document Actions Task Pane?
E.g. rename it 'My Task Pane'?
Oh, Im not using VSTO.
Any help appreciated,
Rob
robsroom A:T h0tmail d0t c0mAnonymous
June 24, 2004
To my knowledge, you cannot change the name displayed.Anonymous
July 14, 2004
how can i cause the pane to become visible from within my code? also, if the research pane is shown, do i have access to the "results" area such that i can populate it with my own well-formed xml?Anonymous
July 14, 2004
When you add a control to the actions pane, the actions pane appears by default.
The research pane is a separate issue. We don't provide any way in Visual Studio Tools for Office for you to create a customized version of the research pane.Anonymous
July 14, 2004
I don't want to create a customized version but rather invoke a web service that is research pane compatible from my own code and simply render the results in the already defined area in the research pane. To accomplish this, I need to 1. force the research pane to become visisble if it isn't already and 2. gain access to the portion of the research pane that shows the response. Is this possible?
Also is there any sample C# code showing an Excel workbook and a custom actions pane? Preferably adding controls dynamically at run-time.
( I'm a MSDN subscriber and ISV partner if that helps)
TIAAnonymous
July 15, 2004
Assuming your user or a remote administrator has deployed the research service to the end-user's computer, this sounds possible. See the Research Service SDK documentation at the MSDN Web site (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rssdk/html/rsconAboutRSSDK.asp?frame=true) for more information.Anonymous
July 10, 2007
Need C# code for custom task pane accessing web service data(URL)for an excel sheet.Anonymous
January 24, 2008
PingBack from http://softwareinformation.247blogging.info/microsoft-visual-studio-tools-for-the-microsoft-office-system-what-is/