Access Add-In Ribbon from Code

BenW71

New Member
Joined
Apr 19, 2018
Messages
26
I need to be able to get a reference to a ribbon that is part of an add-in to invalidate / refresh buttons at times.

I have a module level public variable defined and instantiated when the workbook opens as such...
In the XLAM CustomUI declaration:
VBA Code:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="MyAddInInitialize" >

In a workbook module:
VBA Code:
Public MyRibbon As IRibbonUI

Sub MyAddInInitialize(Ribbon As IRibbonUI)
    Set MyRibbon = Ribbon
End Sub

However sometimes (and i don't know why) the myribbon variable becomes Nothing after being used for a while. I don't really know why...

Instead of tracking down why the variable is being lost which is a valid question but i may not need to solve it, is there a way to access the ribbon object by name or any other object tree? So in the XLAM code modules i could do something like MyWorkbook.Ribbons("blah") or whatever to get the variable?

The ribbon still exists, it is clickable and the actions fire... I just don't have a global variable that i can call to refresh the buttons...

Thanks in advance.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Have a look at @RoryA 's solution in this following thread...


Hope this helps!
 
Upvote 0
Solution
Have a look at @RoryA 's solution in this following thread...


Hope this helps!
Thank you Domenic, this does indeed look like the solution to my issue!

Marking as the solution
 
Upvote 0

Forum statistics

Threads
1,215,072
Messages
6,122,966
Members
449,094
Latest member
Anshu121

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top