How to use Excel/PowerPoint/Word CustomTaskPanes?

Add-in Express™ Support Service
That's what is more important than anything else

How to use Excel/PowerPoint/Word CustomTaskPanes?
 
Martin Henke




Posts: 22
Joined: 2010-12-07
Hello everybody,

I would like to convert a VSTO add-in to an ADX add-in.
However, since I do not want to rewrite the whole code which is related to TaskPanes, I wonder how I could use the CustomTaskPaneCollection in a way that I can create a TaskPane by code, add my user control and then add it to the CustomTaskPane collection. It would be great, if you could provide some sample code that shows how to do it.

Thanks a lot in advance!

Best regards,

Martin
Posted 07 Dec, 2010 12:53:00 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Martin,

There is no ready-made sample add-in project. Please have a look at the Converting existing Office COM add-in projects to Add-in Express and Migrate the code of your Office solution from Win32 and VBA code to .NET articles on our technical blog. Also you may be interested in the Custom task panes and Advanced Excel Task Panes sections of the online documentation.

Anyway, I can prepare a sample project with Custom Task Panes for you if you wish.
.NET, Extended MAPI, Windows Phone & RT
Posted 08 Dec, 2010 05:41:05 Top
Martin Henke




Posts: 22
Joined: 2010-12-07
Hello Eugene,

I had a look at the links you provided, but they just refer to the Advanced Task Panes. However, we want to use the Microsoft (VSTO) task panes (Microsoft.Office.Core.CustomTaskPane).
It would be great, if you had an example which showed how I could create these CustomTaskPanes with Add-in-Express.

Thanks a lot in advance!

Best regards,

Martin
Posted 08 Dec, 2010 05:55:42 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Martin,

I have just sent a sample add-in project to you. Please check out your Inbox.
.NET, Extended MAPI, Windows Phone & RT
Posted 08 Dec, 2010 11:36:59 Top
Martin Henke




Posts: 22
Joined: 2010-12-07
Hello Eugene,

Thanks a lot for your sample, which works fine.

Unfortunately my problem is now that I get an exception when I try to create a TaskPane when the UserControl is in a different library. This is what I get: Das angegebene ActiveX-Steuerelement kann nicht erstellt werden. (meaning: Can't create the specified ActiveX control). Please find my source code at the end of this posting.

Detailed technical information follows:
---
Date and Time: 09.12.2010 16:50:17
Machine Name: not relevant
IP Address: not relevant
Current User: not relevant

Application Domain: C:\Users\henke\Documents\Visual Studio 2010\Projects\MyAddin1\MyAddin1\bin\Debug\
Assembly Codebase: file:///C:/Windows/assembly/GAC_MSIL/AddinExpress.MSO.2005/6.1.3044.2005__4416dd98f0861965/AddinExpress.MSO.2005.dll
Assembly Full Name: AddinExpress.MSO.2005, Version=6.1.3044.2005, Culture=neutral, PublicKeyToken=4416dd98f0861965
Assembly Version: 6.1.3044.2005
Assembly Build Date: 02.05.2008 01:06:50

Exception Source:
Exception Type: System.Runtime.InteropServices.COMException
Exception Message: Das angegebene ActiveX-Steuerelement kann nicht erstellt werden.
Exception Target Site: ForwardCallToInvokeMember

---- Stack Trace ----
System.RuntimeType.ForwardCallToInvokeMember(memberName As String, flags As BindingFlags, target As Object, aWrapperTypes As Int32[], msgData As MessageData&)
AddinExpress.MSO.2005.dll: N 0197 (0xC5) IL
AddinExpress.MSO.ICTPFactory.CreateCTP(CTPAxID As String, CTPTitle As String, CTPParentWindow As Object)
AddinExpress.MSO.2005.dll: N 00000 (0x0) JIT
AddinExpress.MSO.ADXAddinModule.AddCustomTaskPanes(parent As Object, outlookFolderName As String)
AddinExpress.MSO.2005.dll: N 0000 (0x0) IL




Based on your code, my code looks like this:

//Fires an exception
AddUserControlToTaskPanes(this.TaskPanes, out this.components, "ClassLibrary1.UserControl1");


//Works fine
AddUserControlToTaskPanes(this.TaskPanes, out this.components, "MyAddIn1.UserControl1");


public static void AddUserControlToTaskPanes(AddinExpress.MSO.ADXCustomTaskPaneCollection collection, out System.ComponentModel.IContainer container, string userControlName)
{
AddinExpress.MSO.ADXTaskPane adxTaskPane1;
container = new System.ComponentModel.Container();

adxTaskPane1 = new AddinExpress.MSO.ADXTaskPane(container);
//
// adxTaskPane1
//

adxTaskPane1.ControlProgID = userControlName;
adxTaskPane1.OutlookWindows = AddinExpress.MSO.ADXCTPOutlookWindow.olNone;
adxTaskPane1.SupportedApps = AddinExpress.MSO.ADXOfficeHostApp.ohaExcel;

//
// AddinModule
//
collection.Add(adxTaskPane1);
}


Do you have any idea what I do wrong?

Best regards,

Martin
Posted 09 Dec, 2010 10:05:10 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Martin,

I have noticed that you use an old build of Add-in Express:

Assembly Version: 6.1.3044.2005


Please download and install a new build. Don't forget to replace the adxloader.dll in the Loader folder of your project with a new one (see the Redistributables folder). Does it help?
.NET, Extended MAPI, Windows Phone & RT
Posted 09 Dec, 2010 10:22:28 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Martin,

(meaning: Can't create the specified ActiveX control).


Please make sure that you registered an ActiveX control from your type library on the PC.
.NET, Extended MAPI, Windows Phone & RT
Posted 09 Dec, 2010 10:43:26 Top