Gontran Harvey
asked on
Load or unload a ribbon
I would like to be able to load or unload a specidic custom ribbon with code behind a button.
thanks
This not possible in Access. The ribbon is loaded from USysRibbons automatically at program start. You can only modify the visibility of the tabs in the ribbon during runtime.
I assume you want to dynamically change the Ribbon
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/8962f2b5-9b5b-4a4c-a744-dd6cd4988bd8/updating-ribbon-label-at-runtime?forum=exceldev
if you want to "hide it" then
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/8962f2b5-9b5b-4a4c-a744-dd6cd4988bd8/updating-ribbon-label-at-runtime?forum=exceldev
if you want to "hide it" then
DoCmd.ShowToolbar "Ribbon", acToolbarNo
to display it againDoCmd.ShowToolbar "Ribbon", acToolbarYes
Give some more info on what you want to accomplish and we will try to provide you with some more help
ASKER
Ok my goal is that I have a Main custom ribbon with buttons with callback function.Some buttons are enabled based on the role of a user.
Sometime I'm doing some impersonation of a specific user to see how my database react. In this case I want to change the user (without closing the app) and after, refresh the ribbon so I can see the difference of the ribbon (some buttons should or should not be enabled.
Thanks
Sometime I'm doing some impersonation of a specific user to see how my database react. In this case I want to change the user (without closing the app) and after, refresh the ribbon so I can see the difference of the ribbon (some buttons should or should not be enabled.
Thanks
Easy....Ribbon.Invalidate is the key you are looking....
https://sourcedaddy.com/ms-excel/resetting-controls.html
https://sourcedaddy.com/ms-excel/resetting-controls.html
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
ste5an work fine (thanks by the way!) if at the opening I set the "m_Ribbon" variable by placing my custom ribbon as the default, but the problem I have is if a stop the code (all variable are emptied by vba) then my ribbon variable is lost and I can't reach it.
Is there a way when the database is open and the code as been stop, to reload the ribbon and re-fire the "RibbonOnLoad " function.
thanks
Is there a way when the database is open and the code as been stop, to reload the ribbon and re-fire the "RibbonOnLoad " function.
thanks
No.
You need the module level variable. Due to VBA, when your module errors out or breaks, then it is lost and you must reload the database file. There is no way around this.
You need the module level variable. Due to VBA, when your module errors out or breaks, then it is lost and you must reload the database file. There is no way around this.
I'm not sure if that is possible. Normally what I do instead is use the GetVisible callback and through that determine if a particular tab, group or button should be visible. Would that work for your scenario?