Show/Hide advanced office task pane

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

Show/Hide advanced office task pane
 
Siddharth Rout




Posts: 9
Joined: 2020-03-26
Hi

I have 2 queries.

1. I want the taskpane to be hidden when the Add-in starts
2. I want to show the task pane when a button in the ribbon is pressed.

For my first query, I went through the post https://www.add-in-express.com/forum/read.php?FID=5&TID=3288 but I noticed that for it to work, I have to add both the codes and not just one of them.


    Public Class AddinModule
        '
        '
        '
        Private HideByDefault As Boolean = True
    
        Private Sub AdxExcelTaskPanesManager1_ADXBeforeTaskPaneInstanceCreate(sender As Object,
        e As ADXBeforeTaskPaneInstanceCreateEventArgs) Handles AdxExcelTaskPanesManager1.ADXBeforeTaskPaneInstanceCreate
            If (HideByDefault) Then
                e.Cancel = True
                HideByDefault = False
            End If
        End Sub
    End Class


and


    Public Class tskPaneActivity
        '
        '
        '
        Private HideByDefault As Boolean = True
    
        Private Sub tskPaneActivity_ADXBeforeTaskPaneShow(sender As Object,
        e As ADXBeforeTaskPaneShowEventArgs) Handles Me.ADXBeforeTaskPaneShow
            If HideByDefault Then
                Me.Visible = False
                HideByDefault = False
            End If
        End Sub
    End Class


If I use only one of them then it does not work. i.e the task pane remains visible.

Appreciate any help with both my queries.

Sid
Regards

Siddharth Rout
Founder
XPIZON

[Skype]: XPIZON, [Email]: srout@xpizon.com, [Website]: www.SiddharthRout.Com; www.xpizon.com
Posted 27 Aug, 2020 08:46:52 Top
Andrei Smolin


Add-in Express team


Posts: 17361
Joined: 2006-05-11
Hello Siddharth,

Recently, we published updated examples and the Add-in Express manual (the sections above were not changed). Find examples at https://www.add-in-express.com/creating-addins-blog/2020/07/01/sample-com-addin-projects-outlook-excel-powerpoint-word/. The new manual version will be included in the next Add-in Express build. Currently, it is only available at https://www.add-in-express.com/downloads/documentation.php.

ADXBeforeTaskPaneInstanceCreate lets you control the creation of a taskpane instance for the current window.
ADXBeforeTaskPaneShow lets you control the visibility of the taskpane instance created for the current window.

In the example we, use ADXBeforeTaskPaneShow.

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 27 Aug, 2020 10:06:38 Top
Siddharth Rout




Posts: 9
Joined: 2020-03-26
Thanks Andrei. I am facing the same problem with this code as well.

In my Add-in Module


    Public Const showPanesAtStartup As Boolean = True

    Private Sub AdxRibbonButton1_OnClick(sender As Object, control As IRibbonControl, pressed As Boolean) Handles AdxRibbonButton1.OnClick
        Dim context As Object = control.Context
        Dim pane As Logging.ILogPane = GetPane(Me.HostType, context)

        If pane IsNot Nothing Then pane.Show()

        If context IsNot Nothing Then Marshal.ReleaseComObject(context)
    End Sub

    Private Function GetPane(ByVal host As AddinExpress.MSO.ADXOfficeHostApp, ByVal contextWindow As Object) As Logging.ILogPane
        If contextWindow Is Nothing Then Return Nothing

        Dim pane As Logging.ILogPane = Nothing

        pane = TryCast(AdxExcelTaskPanesCollectionItem1.TaskPaneInstance, Logging.ILogPane)

        Return pane
    End Function


In my ADXExcelTaskPane1


    Private letMeShow As Boolean = False

    Private Sub ADXExcelTaskPane1_ADXBeforeTaskPaneShow(ByVal sender As System.Object,
    ByVal e As AddinExpress.XL.ADXBeforeTaskPaneShowEventArgs) Handles MyBase.ADXBeforeTaskPaneShow
        Me.Visible = letMeShow
    End Sub


I have also imported imported Logging.ILogPane

When Excel starts, the panel is hidden as expected because of "Me.Visible = letMeShow" but then "pane = TryCast(AdxExcelTaskPanesCollectionItem1.TaskPaneInstance, Logging.ILogPane)" is returning "Nothing".

Am I missing something here?
Regards

Siddharth Rout
Founder
XPIZON

[Skype]: XPIZON, [Email]: srout@xpizon.com, [Website]: www.SiddharthRout.Com; www.xpizon.com
Posted 27 Aug, 2020 12:20:56 Top
Siddharth Rout




Posts: 9
Joined: 2020-03-26
Thanks Andrie.. I managed it. Much appreciated.
Regards

Siddharth Rout
Founder
XPIZON

[Skype]: XPIZON, [Email]: srout@xpizon.com, [Website]: www.SiddharthRout.Com; www.xpizon.com
Posted 27 Aug, 2020 12:27:38 Top
Andrei Smolin


Add-in Express team


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

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 28 Aug, 2020 03:59:02 Top