Accessing ADXRibbon and ADXCommandBar controls collection

Add-in Express™ Support Service
That's what is more important than anything else

Accessing ADXRibbon and ADXCommandBar controls collection
Kirill Lapin

Posts: 42
Joined: 2011-05-04

Coding an Excel Add-in in VB.NET on VS 2013

Is there any way to access ADXRibbon and ADXCommandBar controls collection instead of creating a variable per button please?

Currently, I am declaring public variables in Globals module like this:

    Imports AddinExpress.MSO

    Public ribbon_button1 As ADXRibbonButton
    Public ribbon_button2 As ADXRibbonButton
    Public ribbon_button3 As ADXRibbonButton
    Public commandbar_button1 As ADXCommandBarButton
    Public commandbar_button2 As ADXCommandBarButton
    Public commandbar_button3 As ADXCommandBarButton

Assigning the controls in the Addin Module Initialize event as follows:

     ribbon_button1 = Me.AdxRibbonButton1
     ribbon_button2 = Me.AdxRibbonButton2
     ribbon_button3 = Me.AdxRibbonButton3

     commandbar_button1 = Me.AdxCommandBarButton1
     commandbar_button2 = Me.AdxCommandBarButton2
     commandbar_button3 = Me.AdxCommandBarButton3

And then manipulate the buttons in a private sub as follows:


What I would like to do is something like this:

    For i As Integer = 1 To 3
        AddinExpress.MSO.ADXRibbonControls(i).Enabled = True
        AddinExpress.MSO.ADXCommandBars(1).Controls(i).Enabled = True


    For Each c As ADXRibbonControl In ADXRibbon.Controls
        c.Enabled = True
    For Each c As ADXCommandBarControl In ADXCommandBars(1).Controls
        c.Enabled = True

Many thanks in advance,

Posted 06 Feb, 2016 15:46:08 Top
Kirill Lapin

Posts: 42
Joined: 2011-05-04
OK. I have worked it around:

Created global array variables in Globals module;

    Public Const intButtonsNumber As Integer = 3
    Public arrRibbonButtons(intButtonsNumber - 1) As ADXRibbonButton
    Public arrCommandBarButtons(intButtonsNumber - 1) As ADXCommandBarButton

And assigned the buttons to arrays in the Addin Module Initialize event:

        arrRibbonButtons(0) = Me.AdxRibbonButton1
        arrRibbonButtons(1) = Me.AdxRibbonButton2
        arrRibbonButtons(2) = Me.AdxRibbonButton3

        arrCommandBarButtons(0) = Me.AdxCommandBarButton1
        arrCommandBarButtons(1) = Me.AdxCommandBarButton2
        arrCommandBarButtons(2) = Me.AdxCommandBarButton3
Posted 06 Feb, 2016 19:08:54 Top
Andrei Smolin

Add-in Express team

Posts: 16986
Joined: 2006-05-11
Thank you for posting this solution, Kirill!

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 08 Feb, 2016 03:31:44 Top