Word Custom TaskPane Programatically

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

Word Custom TaskPane Programatically
 
Albert Siagian


Guest


I use the following code to create Custom Word TaskPane programatically. Similar code works for Excel, but error in Word during ShowTaskPane. What am I missing ?

Thanks
Albert


Friend WithEvents AdxWordTaskPanesManagerTEST As AddinExpress.WD.ADXWordTaskPanesManager
Friend WithEvents AdxWordTaskPanesCollectionItemTEST As AddinExpress.WD.ADXWordTaskPanesCollectionItem

Me.components = New System.ComponentModel.Container()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(AddinModule))
Me.AdxWordTaskPanesManagerTEST = New AddinExpress.WD.ADXWordTaskPanesManager(Me.components)
Me.AdxWordTaskPanesCollectionItemTEST = New AddinExpress.WD.ADXWordTaskPanesCollectionItem(Me.components)
Me.AdxWordTaskPanesManagerTEST.Items.Add(Me.AdxWordTaskPanesCollectionItemTEST)
Me.AdxWordTaskPanesCollectionItemTEST.AlwaysShowHeader = True
Me.AdxWordTaskPanesCollectionItemTEST.Position = AddinExpress.WD.ADXWordTaskPanePosition.Top
Me.AdxWordTaskPanesCollectionItemTEST.TaskPaneClassName = "WordTestTaskPane"
Me.AdxWordTaskPanesCollectionItemTEST.UseOfficeThemeForBackground = True
Me.AdxWordTaskPanesManagerTEST.SetOwner(Me)
Me.AdxWordTaskPanesCollectionItemTEST.Enabled = True
Me.AdxWordTaskPanesCollectionItemTEST.ShowTaskPane()


Here is the error message:

Exception Source: AddinExpress.WD.2005
Exception Type: System.Exception
Exception Message: FindOutlookWindowFactory.GetFindWindowObject: Unknown HostVersion
Exception Target Site: CreateSpecificFindWindowObject

---- Stack Trace ----
AddinExpress.WD.FindWordWindowFactory.CreateSpecificFindWindowObject(ItemType As AdxItemType)
AddinExpress.WD.2005.dll: N 0080 (0x50) IL
AddinExpress.Extensions.FindWindowFactory.CreateFindWindowObject(ItemType As AdxItemType)
AddinExpress.WD.2005.dll: N 0014 (0xE) IL
AddinExpress.Extensions.Utils.GetAppWindowHandle(FHostVersion As Int32, FItemType As AdxItemType, FHostHandle As IntPtr)
AddinExpress.WD.2005.dll: N 4046 (0xFCE) IL
AddinExpress.WD.WordContextArgs.SetActiveContextDocumentType()
AddinExpress.WD.2005.dll: N 0081 (0x51) IL
AddinExpress.WD.WordContextArgs.InitializeActiveContext(HostHandle As IntPtr)
AddinExpress.WD.2005.dll: N 0385 (0x181) IL
AddinExpress.WD.WordContextArgs..ctor(FormsManager As ADXWordTaskPanesManager)
AddinExpress.WD.2005.dll: N 0084 (0x54) IL
AddinExpress.WD.ADXWordTaskPanesCollectionItem.ShowTaskPane()
AddinExpress.WD.2005.dll: N 0001 (0x1) IL
Posted 28 May, 2013 06:38:58 Top
Andrei Smolin


Add-in Express team


Posts: 18794
Joined: 2006-05-11
Hello Albert,

It looks like you use an older Add-in Express version with a more recent word version. If so, you need to install the latest Add-in Express build.


Andrei Smolin
Add-in Express Team Leader
Posted 28 May, 2013 06:49:30 Top
Albert Siagian


Guest


Hello Andrei,

I am using Office 2010 and latest version of Add-In-Express. In the Reference detail for AddinExpress.WD.2005 is 7.2.4055.2005.

It is actually already working if I create the Word TaskManager from GUI (auto-generated code from Add-in-Express. Only manual programatically fails.

One thing to note, that I have both auto-generated Word TaskManager and manual programatically running at same time. Obviously the names are different, otherwise it won't compile. Reason is I am transitioning from auto-generated to manual one. Will that causing issue ? As I mentioned, same case and solution with Excel works fine.

Regards.
Albert
Posted 28 May, 2013 07:21:31 Top
Andrei Smolin


Add-in Express team


Posts: 18794
Joined: 2006-05-11
Hello Albert,

Please move Me.AdxWordTaskPanesManagerTEST.SetOwner(Me) before you add an item to the items colleciton. Also, you must specify the TaskPaneClassName property must contain namespace plus the class nema of the form. You can check the format in the code generated at design time.


Andrei Smolin
Add-in Express Team Leader
Posted 28 May, 2013 08:40:37 Top
Albert Siagian


Guest


Hello Andrei,

Same error, and yes, I use namespace + form name. I change it for posting purpose.

I found a solution/workaround, is that by using the Taskpane Manager from the GUI/Design Time version, instead of the one that I created manually. Only CollectionItem I manually created. So following code works for me now. Don't know if this is Add-in Express bug or bug in my code.

Me.AdxWordTaskPanesCollectionItemTEST = New AddinExpress.WD.ADXWordTaskPanesCollectionItem(Me.components)

Me.GUIWordTaskPanesManager.Items.Add(Me.AdxWordTaskPanesCollectionItemTEST)

Me.AdxWordTaskPanesCollectionItemTEST.AlwaysShowHeader = True
Me.AdxWordTaskPanesCollectionItemTEST.Position = AddinExpress.WD.ADXWordTaskPanePosition.Top
Me.AdxWordTaskPanesCollectionItemTEST.TaskPaneClassName = "namespace.wordtaskpane"
Me.AdxWordTaskPanesCollectionItemTEST.UseOfficeThemeForBackground = True
Me.AdxWordTaskPanesCollectionItemTEST.Enabled = True
Me.AdxWordTaskPanesCollectionItemTEST.ShowTaskPane()


Regards.
Albert
Posted 28 May, 2013 09:24:20 Top