Excel Advanced Task Panes: hide on start up, open from ribbon button, close from button on the pane

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

Excel Advanced Task Panes: hide on start up, open from ribbon button, close from button on the pane
 
Kirill Lapin




Posts: 42
Joined: 2011-05-04
Hi there,

I just need these three seemingly simple things from the Task Pane and I am not able to achieve it:

  • Prevent the Task Pane from showing on addin startup
  • Show the Task Pane on ribbon button click
  • Close the Task Pane by clicking a button located on the Task Pane

All the examples I have found on this site either don't work or are extremely cumbersome/cryptic. It must be me, but I am finding myself spending way too much time trying to make the UI work, reading the manuals, forums and web articles, when this should be exactly the easiest part of the project which is why I bought the ADX. Sorry if I am starting to sound frustrated, because I really am.

I thought it should be as easy as the following, but it is not apparently. I can't believe I need so many variables and additional encapsulated procedures as in this example:How to show an Advanced Excel Task Pane dynamically to achieve what I want. Here is what I have:

1) In the ADXExcelTaskPane1 module:
    Private Sub ADXExcelTaskPane1_ADXBeforeTaskPaneShow(ByVal sender As System.Object, ByVal e As AddinExpress.XL.ADXBeforeTaskPaneShowEventArgs) Handles MyBase.ADXBeforeTaskPaneShow
        Me.Visible = False
    End Sub

2) in the AddinModule:
    Private Sub AdxRibbonButton1_OnClick(sender As Object, control As IRibbonControl, pressed As Boolean) Handles AdxRibbonButton1.OnClick
        Try
            Dim taskPane As AddinExpress.XL.ADXExcelTaskPane = AdxExcelTaskPanesCollectionItem1.TaskPaneInstance
            If taskPane Is Nothing Then
                taskPane = AdxExcelTaskPanesCollectionItem1.CreateTaskPaneInstance()
            End If
            If taskPane IsNot Nothing Then
                taskPane.Visible = True
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

3) in the ADXExcelTaskPane1 module:
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Me.Hide()
    End Sub

Number 1) does prevent the Task Pane from showing on start up. However numbers 2) and 3) seem to work together fine only if number 1) is disabled. For whatever reason number 2) is unable to set the Visible property of the instance to True if the item's Visible property was set to False by number 1).

Any simple way of fixing this please without having to learn the architecture of ADX please?

Many thanks in advance and Season's greetings,
KL

Working on an Excel COM add-in for v2010-2019
Visual Studio 2017 Enterprise
ADX 9.2.4635
Posted 23 Dec, 2018 20:32:05 Top
Kirill Lapin




Posts: 42
Joined: 2011-05-04
OK. I figured it out. I guess with so many nights hitting my head upon the wall I missed the fact that I am preventing the Task Pane from showing through an event (something that doesn't feel right in the first place, but it seems to be the only way according to the available tutorials), which will fire each time I attempt to show the pane and, if the only command in it is to hide, it will never show. So here is the simple solution in case someone else is in my situation:

1) declare a public variable in any simple module (I have two panes [pains?:)] so I need two variables):
Public ShowTaskPane1 As Boolean

2) In the ADXExcelTaskPane1 module:
Private Sub ADXExcelTaskPane1_ADXBeforeTaskPaneShow(ByVal sender As System.Object, ByVal e As AddinExpress.XL.ADXBeforeTaskPaneShowEventArgs) Handles MyBase.ADXBeforeTaskPaneShow 
        Me.Visible = ShowTaskPane1 
End Sub

3) in the AddinModule:
Private Sub AdxRibbonButton1_OnClick(sender As Object, control As IRibbonControl, pressed As Boolean) Handles AdxRibbonButton1.OnClick 
    Try 
        Dim taskPane As AddinExpress.XL.ADXExcelTaskPane = AdxExcelTaskPanesCollectionItem1.TaskPaneInstance 
        If taskPane Is Nothing Then 
            taskPane = AdxExcelTaskPanesCollectionItem1.CreateTaskPaneInstance() 
        End If 
        If taskPane IsNot Nothing Then
            ShowTaskPane1 = True
            taskPane.Visible = True
        End If 
    Catch ex As Exception 
        MessageBox.Show(ex.Message)
    End Try 
    ShowTaskPane1 = False
End Sub 

4) in the ADXExcelTaskPane1 module:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 
    Me.Hide() 
End Sub 


Regards,
KL
Posted 23 Dec, 2018 21:49:30 Top
Andrei Smolin


Add-in Express team


Posts: 16956
Joined: 2006-05-11
Great!

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 24 Dec, 2018 05:23:23 Top