Is Custom Ribbon Loaded? (1 Viewer)

KitaYama

Well-known member
Local time
Tomorrow, 07:32
Joined
Jan 6, 2022
Messages
1,489
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:

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 22:32
Joined
Jul 9, 2003
Messages
16,245
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…
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:32
Joined
May 7, 2009
Messages
19,169
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
 

KitaYama

Well-known member
Local time
Tomorrow, 07:32
Joined
Jan 6, 2022
Messages
1,489
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.
 

PaquettePaul

Member
Local time
Today, 18:32
Joined
Mar 28, 2022
Messages
107
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).?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:32
Joined
Oct 29, 2018
Messages
21,358
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:

PaquettePaul

Member
Local time
Today, 18:32
Joined
Mar 28, 2022
Messages
107
Never heard of TempVars. Will have to look that up. Always learning something new.
 

Users who are viewing this thread

Top Bottom