Invalidate entire Ribbon Tab at runtime?

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

Invalidate entire Ribbon Tab at runtime?
 
Subscribe
Ken Puls




Posts: 34
Joined: 2014-12-17
I'm trying to invalidate all commands on my Ribbon tab at runtime in order to unlock pro features when someone activates their license key. I'm struggling on getting this working, especially since I'm calling it from a windows form, not the AddinModule.

I tried setting up a global variable as follows:
Public g_myRibbonTab As AddinExpress.MSO.ADXRibbonTab


And capturing the tab to that variable during the addinInitialize event as follows:
g_myRibbonTab = CurrentInstance.rxMonkeyTools


That seemed to work, but this code doesn't have any effect when run from my form:
g_myRibbonTab.Invalidate()


Do I have to go after each control? As I have several, I was hoping not to have to do that...
Ken Puls, FCPA, FCMA, MS MVP
Posted 23 Jan, 2024 23:56:50 Top
Andrei Smolin


Add-in Express team


Posts: 18833
Joined: 2006-05-11
Hello Ken,

Invalidating a tab should cause components located on the tab to re-read their properties. This is made by raising the PropertyChanging event on every component. If you intercept that event make sure it is invoked.

There's a possibility that Office performs the invalidation at the moment when Office thinks it is suitable. Say, if your form is shown modally, try to close it and open another workbook: does the invalidation work?

Regards from Poland (GMT+1),

Andrei Smolin
Add-in Express Team Leader
Posted 24 Jan, 2024 15:10:07 Top
Ken Puls




Posts: 34
Joined: 2014-12-17
Hi Andrei,

Yes, it was working if I switched workbooks, but that's obviously not ideal. I assume that this is because Excel figures the tab is already there for that workbook, so no need to refresh it until you activate a different book.

I gave up on invalidating the entire tab, and just went with the top level button/menu and dynamic menu controls on the tab. So with this in a Globals module, I can pretty much invalidate all controls on demand with immediate effect:

    Public Sub InvalidateRibbonControls()

        With AddinModule.CurrentInstance
            .Adx_QueryMonkey.Invalidate()
            .Adx_TimeSleuth.Invalidate()
            .Adx_MeasureMonkey.Invalidate()
            .Adx_PivotsAndFilters.Invalidate()
            .Adx_ModelSleuth.Invalidate()
            .Adx_ConnectTo.Invalidate()
            .Adx_ImportExport.Invalidate()
            .Adx_ContextCellMenu.Invalidate()
        End With

    End Sub


Thanks for the reply!
Ken Puls, FCPA, FCMA, MS MVP
Posted 25 Jan, 2024 00:13:10 Top
Andrei Smolin


Add-in Express team


Posts: 18833
Joined: 2006-05-11
You are welcome!

Regards from Poland (GMT+1),

Andrei Smolin
Add-in Express Team Leader
Posted 25 Jan, 2024 09:08:06 Top