Dirk Anacker
Posts: 2
Joined: 2023-07-30
|
Hi,
I've successfully created my first Excel Taskpane.
I'm able to react on the before and after cell changes.
now I want to react on a click in another cell. (no changes just click)
However, I can't find an event for this.
Already tried with
Private WithEvents myADXExcelAppEvents As ADXExcelAppEvents
sub..... Handles myADXExcelAppEvents.SheetSelectionChanges
intercepting an event doesn't work.
Which event can I use for this and what do I have to include for it
regards
Dirk |
|
Andrei Smolin
Add-in Express team
Posts: 19122
Joined: 2006-05-11
|
Hello Dirk,
Put an ADXExcelAppEvents onto the add-in module, click it, switch to the Events tab of the Properties window, and double-click the SheetSelectionChange (not SheetSelectionChanges) event to create an event handler. Search the forum to find how to handle this event. This event fires whenever you select another cell (range); it doesn't fire if you select a shape.
Regards from Poland (GMT+2),
Andrei Smolin
Add-in Express Team Leader |
|
Dirk Anacker
Posts: 2
Joined: 2023-07-30
|
Hello Andrej,
thanks that was the glue I need 'Put an ADXExcelAppEvents onto the add-in module'
Now my code to get the current Excelcell looks like
Is there a maybe better way e.g. to do it directly in the ADXExcelTaskPane.vb ?
Private Sub AdxExcelAppEvents1_SheetSelectionChange(sender As Object, sheet As Excel.Worksheet, range As Excel.Range) Handles AdxExcelAppEvents1.SheetSelectionChange
currentExcelTaskpane = Me.AdxExcelTaskPanesCollectionItem1.TaskPaneInstance
If TypeOf (currentExcelTaskpane.ActiveControl) Is TextBox And currentExcelTaskpane.ActiveControl.Tag = "ExcelCell" Then
currentExcelTaskpane.ActiveControl.Text = range.Address.ToString()
End If
End Sub
|
|
Andrei Smolin
Add-in Express team
Posts: 19122
Joined: 2006-05-11
|
Hello Dirk,
Me.AdxExcelTaskPanesCollectionItem1.TaskPaneInstance returns an AdxExcelTaskPane or null (Nothing in VB.NET). If it isn't Nothing, you can cast it to the actual type of your task pane (e.g. AdxExcelTaskPane1). If the cast is okay, you can call a method setting the text of that textbox. The method can be defined on your task pane class - this allows you to declare the control itself Private thus hiding it from other parts of your add-in so that the textbox is only updated via that method. This diminishes the number of links between parts your code and thus makes it less complex.
Regards from Poland (GMT+2),
Andrei Smolin
Add-in Express Team Leader |
|