Is Custom Ribbon Loaded?

KitaYama

Well-known member
Local time
Today, 20:07
Joined
Jan 6, 2022
Messages
2,113
Is there any way to check if a certain custom ribbon is loaded or not?

At present I'm using an error trap. If error No is 32610, the ribbon is already loaded.
But I really hate to cause an error and then use error handler to get ride of.
If possible I prefer not to trigger the error at all.

Code:
On Error GoTo ErrorTrap
................
ErrorTrap:
    Select Case Err
        Case 32609, 32610
            ' Ribbon already loaded
            ....Do This
        case else
 
    End SELECT

I know I can use this :
Code:
MsgBox CurrentDb.Properties("MyCustomRibbon")

But it works only after the custom ribbon is loaded. If I use it before custom ribbon is loaded, I receive a property doesn't exist error.

Thank you.
 
Last edited:
Is there any way to check if a certain custom ribbon is loaded or not?

I noticed that your question appears to have been overlooked. I am bumping it up the list to give it another chance at receiving some attention…
 
create a Public boolean variable for each ribbon, eg:

Global gbolRibbonName1 As Boolean
Global gbolRibbonName2 As Boolean

when you load Ribbon1, set gbolRibbonName1 to True.
etc.

you just test the boolean variable "associated" with your ribbon:

If gbolRibbonName1 Then
'already loaded
'ofcourse if there is a Unload method for this
'ribbon, you set the associated variable as False.
Else
'load the ribbon
gbolRibbonName1 = True
End if
 
Thanks but I don't think it will work.
In case of any unhandled error, global variables will be destroyed. So I'm trying to stay away of them.
Do you think tempVars can be used?

thanks again for any insight.
 
KitiYama’s second comment indicated that any unhandled error will cause global variables to be destroyed. First, what is an unhandled error - I capture unknown form errors and write to an error log and is that considered handled? Second, is this a true statement re variables being destroyed (which I assume means values set to null).?
 
1. Yes, anything you didn't trap with an error handler will be an unhandled error, and
2. Yes, it's true. Global variables will lose their assigned values when that happens. However, TempVars retain theirs.
 
Last edited:
Never heard of TempVars. Will have to look that up. Always learning something new.
 

Users who are viewing this thread

Back
Top Bottom