Task Panes code won't work in 2010

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

Task Panes code won't work in 2010
 
Kirill Lapin


Guest


Hi there,

The following code works in XL2013 and 2016, but doesn't in 2010. Any ideas please?

In Globals.vb:
    Public ShowTaskPane1 As Boolean
    Public ShowTaskPane2 As Boolean
    Public ShowTaskPane3 As Boolean

In ADXExcelTaskPane1.vb, ADXExcelTaskPane2.vb and ADXExcelTaskPane3.vb
    Private Sub ADXExcelTaskPane#_ADXBeforeTaskPaneShow(ByVal sender As Object, ByVal e As ADXBeforeTaskPaneShowEventArgs) Handles MyBase.ADXBeforeTaskPaneShow
        Visible = ShowTaskPane#
    End Sub

    Private Sub ADXExcelTaskPane#_Load(sender As Object, e As EventArgs) Handles Me.Load
        Width = 330
        If Not Active Then
            Activate()
        End If
    End Sub

In AddinModule.vb:
    Public Sub ToggleTaskPaneVisibility(ByVal item As Integer, ByVal status As Boolean)
        'Since the property Visible setting is assigned to an event it is handled via global variable
        Try
            Select Case item
                Case 1
                    Dim taskPane As ADXExcelTaskPane1 = TryCast(Me.AdxExcelTaskPanesCollectionItem1.TaskPaneInstance, ADXExcelTaskPane1)
                    If taskPane Is Nothing Then
                        taskPane = AdxExcelTaskPanesCollectionItem1.CreateTaskPaneInstance()
                    End If
                    If taskPane IsNot Nothing Then
                        ShowTaskPane1 = status
                        taskPane.Visible = status
                    End If
                Case 2
                    Dim taskPane As ADXExcelTaskPane2 = TryCast(Me.AdxExcelTaskPanesCollectionItem2.TaskPaneInstance, ADXExcelTaskPane2)
                    If taskPane Is Nothing Then
                        taskPane = AdxExcelTaskPanesCollectionItem2.CreateTaskPaneInstance()
                    End If
                    If taskPane IsNot Nothing Then
                        ShowTaskPane2 = status
                        taskPane.Visible = status
                    End If
                Case 3
                    Dim taskPane As ADXExcelTaskPane3 = TryCast(Me.AdxExcelTaskPanesCollectionItem3.TaskPaneInstance, ADXExcelTaskPane3)
                    If taskPane Is Nothing Then
                        taskPane = AdxExcelTaskPanesCollectionItem3.CreateTaskPaneInstance()
                    End If
                    If taskPane IsNot Nothing Then
                        ShowTaskPane3 = status
                        taskPane.Visible = status
                    End If
                Case Else
            End Select
        Catch ex As NullReferenceException

        End Try
    End Sub

    Public Function GetTaskPane1() As ADXExcelTaskPane1
        Return TryCast(Me.AdxExcelTaskPanesCollectionItem1.TaskPaneInstance, ADXExcelTaskPane1)
    End Function

    Public Function GetTaskPane2() As ADXExcelTaskPane2
        Return TryCast(Me.AdxExcelTaskPanesCollectionItem2.TaskPaneInstance, ADXExcelTaskPane2)
    End Function

    Public Function GetTaskPane3() As ADXExcelTaskPane3
        Return TryCast(Me.AdxExcelTaskPanesCollectionItem3.TaskPaneInstance, ADXExcelTaskPane3)
    End Function

    'Show ADXExcelTaskPane1 from a ribbon button
    Private Sub AdxRibbonButton1_OnClick(sender As Object, control As IRibbonControl, pressed As Boolean) Handles AdxRibbonButton1.OnClick
        Call ToggleTaskPaneVisibility(item:=1, status:=True)
    End Sub

In ADXExcelTaskPane1.vb
    Private Sub OcbView11_V1BtnNextClick(sender As Object, e As EventArgs) Handles OcbView11.V1BtnNextClick
        'Show TreeView pane
        Dim taskPane2 As ADXExcelTaskPane2 = AddinModule.GetTaskPane2
        If taskPane2 IsNot Nothing Then
            AddinModule.ToggleTaskPaneVisibility(item:=2, status:=True)
            If Not taskPane2.Active Then
                taskPane2.Activate()
            End If
        End If
        'Show DataGridView pane
        Dim taskPane3 As ADXExcelTaskPane3 = AddinModule.GetTaskPane3
        If taskPane3 IsNot Nothing Then
            AddinModule.ToggleTaskPaneVisibility(item:=3, status:=True)
            If Not taskPane3.Active Then
                taskPane3.Activate()
            End If
        End If
    End Sub

THE ISSUE: In XL2010, the variables taskPane2 and taskPane3 of the last procedure are Nothing after the assignment. This doesn't happen in XL2013 and 2016. ADXExcelTaskPane1 shows no problem when called from the AddinModule.vb.

Thanks,
Kirill
Posted 27 Dec, 2018 16:35:54 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Kirill,

Could you please send us a sample project that includes the code above?


Andrei Smolin
Add-in Express Team Leader
Posted 28 Dec, 2018 06:14:18 Top
Kirill Lapin


Guest


Thanks Andrei. Sent.
Posted 28 Dec, 2018 08:53:14 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Kirill,

Thank you for the project. We cannot reproduce the issue: the panes the add-in creates are shown correctly in all supported applications in Office 2010-2016.

Please avoid calling Activate in From_Load; comment out that line.

You get Nothing because the task pane instance isn't created yet. You need to call CreateTaskPaneInstance to get a new task pane instance created.


Andrei Smolin
Add-in Express Team Leader
Posted 28 Dec, 2018 10:28:51 Top
Kirill Lapin


Guest


Hi Andrei,

The issue is consistent on my machine (Office 97 through 2016 installed)

I have commented the Activate in Form_Load, and the result is exactly the same. So on one hand we can conclude that the use of Activate was not justified.

On the other hand, the issue remains: the panes 2 and 3 don't open under XL2010, but do under 2013 and 2016 on at least one machine (mine :)). I do get that Nothing is because the task pane instance isn't created yet. However all of this raises two questions:

1. If your explanation is correct, how come it is possible that on the same event the task pane instance isn't created yet under XL2010 and red under XL2013/2016?

2. What would be the correct way to implement this sequence so that it works on all machines?

Thanks,
KL
Posted 28 Dec, 2018 10:50:10 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Kirill,

Having several Office versions installed creates issues that cannot be solved programmatically.

Microsoft doesn't recommend doing this (see below); Add-in Express doesn't support such configurations.

Microsoft had a page (https://support.microsoft.com/en-us/kb/290576 it is now deleted) that said that all Office versions should be installed in the natural order. This was only the very first requirement; I don't know how updating a single Office version is treated in this case. Anyway, breaking this rule (or even starting a given Office application of a given version) writes this or that version to the registry: when your code (Add-in Express code) requires to create an instance of that Office application, the application version written in the registry starts, not the version you assume should be started. This creates a mess which cannot be solved programmatically. Note that no issue shows itself in the Office UI; you only see issues when using Office programmatically. Again, there were separate sets of restrictions applied to every given Office application. Alas, this information is missing on their site. I assume this occurs because they stopped supporting Office versions that were affected by these issues.

As far as I know, these restrictions do not apply to Office deployed via Click-to-run. This info requires verification, however.

Whether the above is the direct cause of the issue that you experience, I can't tell. I suggest that you check if the issue is reproducible on another machine; yours isn't good for this purpose.


Andrei Smolin
Add-in Express Team Leader
Posted 28 Dec, 2018 11:15:27 Top
Kirill Lapin


Guest


Thanks Andrei. I will test on a separate machine. If you are right, it will be the first time I run into such an issue having spent decades with multiple Office versions installed on my PC, including a decade as a MS Excel MVP :)
Happy the upcoming New Year!
Kirill
Posted 28 Dec, 2018 16:08:30 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Kirill,

Please check this blog: https://blogs.msdn.microsoft.com/andreww/2007/06/08/why-is-vs-development-not-supported-with-multiple-versions-of-office/


Andrei Smolin
Add-in Express Team Leader
Posted 31 Dec, 2018 05:01:15 Top
Kirill Lapin


Guest


Thanks Andrei! Very helpful as always. Will let you know the results of my testing after the holidays.

Regards,
Kirill
Posted 31 Dec, 2018 08:17:09 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Kirill,

Happy New Year!

I've happened to find a variant of the article missing at https://support.microsoft.com/en-us/kb/290576; see https://support.microsoft.com/en-us/help/2784668/how-to-use-office-2013-suites-and-programs-msi-deployment-on-a-compute.


Andrei Smolin
Add-in Express Team Leader
Posted 02 Jan, 2019 04:43:42 Top