Kirill Lapin
Guest
|
Hi there,
I am unable to make this work for the life of me: https://www.add-in-express.com/docs/net-custom-task-panes.php
I start a new projects and follow every step. If I just follow it, I get a bunch of compiling errors in VS2017 for both snippets provided (the first in ADXExcelTaskPane1.vb and the second in AddinModule.vb)
Severity Code Description Project File Line Suppression State
Error BC30002 Type 'Excel.Range' is not defined. MyAddin2 G:...Visual Studio 2017source
eposMyAddin2MyAddin2ADXExcelTaskPane1.vb 15 Active
Error BC30506 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. MyAddin2 G:...Visual Studio 2017source
eposMyAddin2MyAddin2AddinModule.vb 58 Active
Error BC30506 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. MyAddin2 G:...Visual Studio 2017source
eposMyAddin2MyAddin2AddinModule.vb 65 Active
Error BC30506 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. MyAddin2 G:...Visual Studio 2017source
eposMyAddin2MyAddin2AddinModule.vb 72 Active
I then add to the ADXExcelTaskPane1.vb the following code
Imports Microsoft.Office.Interop
and to the AddinModule:
Friend WithEvents adxExcelEvents As AddinExpress.MSO.ADXExcelAppEvents
And the errors go away, but the Excel events won't fire. The label text won't change with the range selection change. If I use ADXExcelTaskPane1 control events they do work.
Any ideas please?
Thanks,
KL
P.S. Yes, I did run the debugger to see if any of the events worked and they simply didn't. The following code was never invoked:
Private Sub RefreshPane()
Dim selection As Excel.Range = _
CType(Me.ExcelApp.Selection, Excel.Range)
Dim instance As ADXExcelTaskPane1 = _
CType(AdxExcelTaskPanesCollectionItem1.TaskPaneInstance, _
ADXExcelTaskPane1)
If instance IsNot Nothing Then
If Not instance.Visible Then instance.Show()
instance.RefreshMe(selection)
End If
Marshal.ReleaseComObject(selection)
End Sub |
|
Andrei Smolin
Add-in Express team
Posts: 18821
Joined: 2006-05-11
|
Hello Kirill,
At https://www.add-in-express.com/downloads/adxnet.php, please find and download the file labelled as Add-in Express for Office and .NET sample projects. In the archive, find this sample project {ZIP}\Documentation Samples\Your First Microsoft Office COM Add-in\.
Please let me know if that sample project works for you.
Andrei Smolin
Add-in Express Team Leader |
|
Kirill Lapin
Guest
|
Hi Andrei,
The sample file works. Now I need to find the 10 differences with my or the tutorial code :(
Since I figured out how to show task pane from the ribbon, I will postpone this a bit :)
Regards,
KL |
|
Kirill Lapin
Guest
|
OK. Here is the deal. The difference between my solution and the sample solution (and the tutorial) is as follows:
- in my solution automatically generated by ADX the components are initialised in the designer, while in the sample prject they are initialized in the AddinModule.vb (not essential, but explains why I couldn't spot the problem)
- Most importantly, in my solution the events are declared and initialized under the alias 'AdxExcelAppEvents1', while in the sample and tutorial 'adxExcelEvents' is used.
Not sure how this is possible and why so strange alias, but that is what it is. If I change the event sub to the following, it works:
Private Sub adxExcelEvents_SheetSelectionChange( _
ByVal sender As System.Object, _
ByVal sheet As System.Object,
ByVal range As System.Object) _
Handles AdxExcelAppEvents1.SheetSelectionChange
RefreshPane()
End Sub |
|
Dmitry Kostochko
Add-in Express team
Posts: 2875
Joined: 2004-04-05
|
Hi Kirill,
Thank you for keeping us informed.
If you have any questions or face problems feel free to contact us. |
|