none
VB.Net Equivalent RRS feed

  • Question

  • Hi

    I posted this on VB.Net forum but one answer suggested I might be able to get help from here.

    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 Sub

    Sub 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?


    Sidaan


    • Edited by Sidaan Wednesday, April 17, 2013 6:59 AM
    Wednesday, April 17, 2013 6:59 AM

All replies