Kirill Lapin
Guest
|
Hello,
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:
ribbon_button1.Enabled=True
ribbon_button2.Enabled=True
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
Next
or
For Each c As ADXRibbonControl In ADXRibbon.Controls
c.Enabled = True
Next
For Each c As ADXCommandBarControl In ADXCommandBars(1).Controls
c.Enabled = True
Next
Many thanks in advance,
Kirill |
|
Kirill Lapin
Guest
|
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 |
|
Andrei Smolin
Add-in Express team
Posts: 18794
Joined: 2006-05-11
|
Thank you for posting this solution, Kirill!
Andrei Smolin
Add-in Express Team Leader |
|