Ribbon before AutoExec (1 Viewer)

smig

Registered User.
Local time
Today, 18:42
Joined
Nov 25, 2009
Messages
2,209
I have an AutoExec function

How can I force the Ribbon to show before the AutoExec function end ?
 
Autoexec runs first so I don't think you can.
Perhaps use a startup form instead with the autoexec code in the form load event....?
 
Autoexec runs first so I don't think you can.
Perhaps use a startup form instead with the autoexec code in the form load event....?

Thanks
The same idea I had.
Hoped there is another solution :rolleyes:
 
remove the ribbon name from access Option.
on autoexec add a code that will run a Function that will load your ribbon.
after calling the function from the macro, run other part of the macro.
see this link on manually loading the ribbon.
https://docs.microsoft.com/en-us/office/vba/api/Access.Application.LoadCustomUI

I added these lines to the start of my AutoExec function (It run from the AutoExec macro)
Code:
' --- Load the Ribbon
strRibbonName = "Ribbon_NoamLekochot"
strRibbonXML = DLookup("[RibbonXml]", "USysRibbons", "[RibbonName] = '" & strRibbonName & "' ")
Application.LoadCustomUI strRibbonName, strRibbonXML
But I get an error "32610 - Can't load Ribbon_NoamLekochot already loaded" :(
If I give the ribbon another name no ribbon loaded
I removed the Ribbon from the application options
 
Last edited:
Is there any perticular reason you're looking for another solution?


The sample database at the bottom of this post may help.
https://www.access-programmers.co.uk/forums/showthread.php?t=306197

https://www.access-programmers.co.uk/forums/attachment.php?attachmentid=75903&d=1565334844

I do many checks and tests before I load the Login form.
When the Login form loaded the Ribbon already work and it's OK, but it's not working during all the checks and tests.

I just don't want to have an empty form on screen, for this.

I already use most of the things in your guide (All the "OnLoad", "OnAction", "GetVisible"....)
I'll might dig dipper into it :)
 
Is there any particular reason you're looking for another solution?


The sample database at the bottom of this post may help.
https://www.access-programmers.co.uk/forums/showthread.php?t=306197

This "Ribbon Name" is unclear to me.
In my code it is written as:
Code:
Public objRibbonName As IRibbonUI

Code:
Public Sub Ribbon_OnLoad(ribbon As IRibbonUI)

Set objRibbonName = ribbon
objRibbonName.Invalidate
....
I can't find this "Ribbon Name" Other then this place, so basicely iis it possible to use any name you like, enen $%^& ?
Can I use the same name I gave it in the usRibbon table ?
 
I didn’t recommend LoadCustomUI as it’s never worked for me.
However the method I suggested is used in several of my apps and does work for me. I have the ribbon loaded in Access options.

If you are still using a function called autoexec I suggest you rename it to avoid confusing Access


EDIT BTW the startup form can be hidden if you wish
 
Last edited:
I didn’t recommend LoadCustomUI as it’s never worked for me.
However the method I suggested is used in several of my apps and does work for me. I have the ribbon loaded in Access options.

If you are still using a function called autoexec I suggest you rename it to avoid confusing Access


EDIT BTW the startup form can be hidden if you wish
I tried your suggestion
Ribbon won't show once I load a MsgBox or a PopUp Modale form either from the OnLoadEvent or the OnOpen code of this Hidden frmAutoExec form :mad:
 
so you need to load the ribbon first before the login?
remove the opening of the from from autoexec macro.
put it on the OnLoad event of the ribbon:
Code:
Public Sub Ribbon_OnLoad(ribbon As IRibbonUI)

Set objRibbonName = ribbon
objRibbonName.Invalidate
[COLOR="Blue"]DoCmd.OpenForm "frmName"[/COLOR]
 
so you need to load the ribbon first before the login?
remove the opening of the from from autoexec macro.
put it on the OnLoad event of the ribbon:
Code:
Public Sub Ribbon_OnLoad(ribbon As IRibbonUI)

Set objRibbonName = ribbon
objRibbonName.Invalidate
[COLOR="Blue"]DoCmd.OpenForm "frmName"[/COLOR]

Do you suggest to call the AutoExec routines from the Ribbon's OnLoad ?
 
no, what does autoexec do?
if you can move all the code to ribbon_onload, why not.
 
I tried your suggestion
Ribbon won't show once I load a MsgBox or a PopUp Modale form either from the OnLoadEvent or the OnOpen code of this Hidden frmAutoExec form :mad:

OK now it makes sense.
Do you have to include both of those at startup?
If you must have both of those then I suggest you add a timer event to the hidden startup form to delay each of those by say 1 second to give the ribbon time to load. Once the timer event is triggered, reset the timer interval to zero so it is disabled.

Just to clarify
1. You do have the custom ribbon loaded in Access options?
2. You no longer have an autoexec macro?
 
no, what does autoexec do?
if you can move all the code to ribbon_onload, why not.

The AutoExec do a lot of checks and tests, like making sure db file exist.

Tried to run the AutoExec function from the end of the Ribbon OnLoad event, after the Set objRibbonName = ribbon and objRibbonName.Invalidate with no luck :(
Even a DoEvent didn't help
 
before i gave the code i tested it on mine
and it works.
 
OK now it makes sense.
Do you have to include both of those at startup?
If you must have both of those then I suggest you add a timer event to the hidden startup form to delay each of those by say 1 second to give the ribbon time to load. Once the timer event is triggered, reset the timer interval to zero so it is disabled.

Just to clarify
1. You do have the custom ribbon loaded in Access options?
2. You no longer have an autoexec macro?
1. yes, the Ribbon is in the Access' options
2. How can I open this form with no AutoExec macro?
 
rename autoexec macro.
run it on form or code:

DoCmd.RunMacro "macroname"
 
before i gave the code i tested it on mine
and it works.

not working for me :(
even putting a simple MsgBox "x" at the end of the Ribbon's OnLoad event will stop ribbon from loading, and it will load only after closing the MsgBox :(

What I do wrong ?
 

Users who are viewing this thread

Back
Top Bottom