Manipulating Excel Ribbon

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi
I got the following VBA code to manipulate Excel ribbon.
All the following procedures and declarations are in a Module
-------------------------------------------------------------------------------
Public rx_oRibbon As IRibbonUI
Public blnGetLabelState As Boolean
Public blnHomeTabVisibility As Boolean

Sub rxtglBtn1_getLabel(control As IRibbonControl, ByRef returnedVal)
Select Case blnGetLabelState
Case True
returnedVal = "Hide Excel Tabs"
Case False
returnedVal = "Show Excel Tabs"
End Select
End Sub
Sub rxRibbon_onLoad(Ribbon As IRibbonUI)
Set rx_oRibbon = Ribbon
ThisWorkbook.ribbonUI = Ribbon
blnGetLabelState = False
blnHomeTabVisibility = False
End SubSub TabView_getVisible(control As IRibbonControl, ByRef returnedVal)
returnedVal = (blnGetLabelState)
End Sub
Sub rxtglBtn1_Click(control As IRibbonControl, pressed As Boolean)
On Error GoTo a
blnGetLabelState = pressed
rx_oRibbon.Invalidate
Exit Sub
a:
MsgBox ("It appears something has gone wrong. " & _
"Please restart the app.")
End Sub

Then I have got the following in ThisWorkBook
----------------------------------------------------------Private variables to hold state of Ribbon and Ribbon controls
Private pRibbonUI As IRibbonUI
Public Property Let ribbonUI(iRib As IRibbonUI)
Set RibbonUI to property for later use
Set pRibbonUI = iRib
End Property

Public Property Get ribbonUI() As IRibbonUI
Retrieve RibbonUI from property for use
Set ribbonUI = pRibbonUI
End Property
-------------------------------------------------------------------------------
The above code with some XML get a new ribbon for the workbook. I am not able to translate this to VB.Net. Could a programmer help please?
Thanks.
Sidaan

View the full article
 
Back
Top