Excel Taskpane selecton change Event

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

Excel Taskpane selecton change Event
Need Excel Taskpane selecton change Event 
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
Posted 30 Jul, 2023 20:44:47 Top
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
Posted 31 Jul, 2023 10:13:26 Top
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
Posted 31 Jul, 2023 12:05:20 Top
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
Posted 01 Aug, 2023 14:12:46 Top