I created an "Excel VSTO document-level" project in Visual Studio. I have a pre designed "Action Pane" and a Tab Ribbon with a button in it to show my action pane.
My problem is my action pane keeps popping up (show) at least 1 time and quickly disappears before I do anything.
Here is my code so far in my ribbon:
Imports Microsoft.Office.Tools.Ribbon
Public Class Ribbon1
Dim actionsPane1 As New ActionsPaneControl1()
Private Sub Ribbon1_Load(ByVal sender As System.Object, ByVal e As RibbonUIEventArgs) Handles MyBase.Load
Globals.ThisWorkbook.ActionsPane.Clear()
Globals.ThisWorkbook.ActionsPane.Controls.Add(actionsPane1)
actionsPane1.Hide()
Globals.ThisWorkbook.Application.DisplayDocumentActionTaskPane = False
End Sub
Dim boolAP1toggle As Boolean = True
Private Sub Button1_Click(sender As Object, e As RibbonControlEventArgs) Handles Button1.Click
If boolAP1toggle = True Then
Globals.ThisWorkbook.Application.DisplayDocumentActionTaskPane = True
actionsPane1.Show()
boolAP1toggle = False
Else
Globals.ThisWorkbook.Application.DisplayDocumentActionTaskPane = False
actionsPane1.Hide()
boolAP1toggle = True
End If
End Sub
End Class
2
Answers
I found my mistake:
will inevitably show Actions Pane at the time when you try to add any form to it, so I needed to add it my Button1_Click event handler
There is no need to show or hide methods of the pane class. Instead, you need to rely on the DisplayDocumentActionTaskPane property which is set to
true
to display the Document Actions task pane; set tofalse
to hide the Document Actions task pane.