Avatar of Gontran Harvey
Gontran HarveyFlag for Canada

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

Microsoft AccessVBAMicrosoft ExcelMicrosoft Office

Avatar of undefined
Last Comment
ste5an
Avatar of Anders Ebro (Microsoft MVP)
Anders Ebro (Microsoft MVP)
Flag of Denmark image

Hi Gontran
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?
Avatar of ste5an
ste5an
Flag of Germany image

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
DoCmd.ShowToolbar "Ribbon", acToolbarNo

Open in new window

to display it again
DoCmd.ShowToolbar "Ribbon", acToolbarYes

Open in new window

Give some more info on what you want to accomplish and we will try to provide you with some more help
Avatar of Gontran Harvey

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
Easy....Ribbon.Invalidate is the key you are looking....
https://sourcedaddy.com/ms-excel/resetting-controls.html
ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Gontran Harvey

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
Avatar of ste5an
ste5an
Flag of Germany image

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.
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo