I have a ribbon called Ribbon 1
I want my ribbon to show only when a workbook is open. If only the excel application is running and no workbooks are open then I want to hide my ribbon tab. How can I do that?
This is what I tried but it is not hiding the ribbon
Public Class ThisAddIn
Private Sub Application_WorkbookOpen(ByVal doc As Excel.Workbook) Handles Application.WorkbookOpen
If Application.Workbooks.Count > 0 Then
If Globals.Ribbons.Ribbon1.Tab1.Visible = False Then Globals.Ribbons.Ribbon1.Tab1.Visible = True
End If
End Sub
Private Sub Application_WorkbookBeforeClose(ByVal doc As Excel.Workbook, ByRef Cancel As Boolean) Handles Application.WorkbookBeforeClose
If Application.Workbooks.Count = 1 Then
If Globals.Ribbons.Ribbon1.Tab1.Visible = True Then Globals.Ribbons.Ribbon1.Tab1.Visible = False
End If
End Sub
End Class
I am not getting any error. It is simply not hiding it. I put a break point on If Globals.Ribbons.Ribbon1.Tab1.Visible = True Then Globals.Ribbons.Ribbon1.Tab1.Visible = False. The line executed but the tab didn't hide. I am having a brain freeze! Is this the right way to do what I want?
