PDA

View Full Version : RibbonX Custom Tab to show up upon opening



dkesar
12-28-2014, 03:27 AM
I have created a ribbon from scratch and all is fine. Only two tabs and each called depending on a active worksheet. My only problem is ribbon does not show up when doc opens. No errors. I have to click on another sheet and ribbon loads. Is there any way I can correct this and have ribbon loaded immediately when doc openes? Below is code I have used to load the custom UI


Private Sub Workbook_SheetActivate(ByVal sh As Object)
Select Case sh.CodeName
Case "Sheet2": Call RefreshRibbon(Tag:="Cover")
Case Else: Call RefreshRibbon(Tag:="Schedule")
End Select

End Sub

dkesar
12-28-2014, 03:42 AM
..and I have forgot to mention below code is present in RibbonModule in order to load ribbon


Option Explicit

Dim Rib As IRibbonUI
Dim MyTag As String

Sub RibbonOnLoad(ribbon As IRibbonUI)
Set Rib = ribbon
End Sub

Sub GetVisible(control As IRibbonControl, ByRef visible)
If MyTag = "show" Then
visible = True
Else
If control.Tag Like MyTag Then
visible = True
Else
visible = False
End If
End If
End Sub

Sub RefreshRibbon(Tag As String)
MyTag = Tag
If Rib Is Nothing Then
MsgBox "Error, restart your workbook"
Else
Rib.Invalidate
End If
End Sub