How to ignore events during initialization?

I’m obviously doing something wrong. At load time, LO seems to be firing all kinds of events (some multiple times) before initialization can be completed. So my macros tied to events are trying to run before other prerequisite entities are instantiated and/or initialized. Naturally, this throws a lot of errors about variables and objects that can’t be found yet. This is so problematic… surely there is some manual written explaining how to avoid this. Yes, no? My hack to try to avoid it is a global boolean variable called gblStartupIsCompleted. And the first line of code in all but one of my macros is: “if NOT gblStartupIsCompleted then exit sub”. It works pretty good but it is difficult to figure out when to set my global variable to TRUE… So 1) is there an easier way to do this?..or…2) what is the final load/initialize event at startup where gblStartupIsCompleted can be set to TRUE? Oh…using LO:7.1.8.1 (x64) on Windows10 pc.

Presumably the ‘Open Document’ event occurs to early to set your variable? Which events are ‘misfiring’?

Uh… hmmmm there are really a LOT of macros and events and you can imagine it is really difficult to track down what the firing sequence is other than to put msgboxes all over the place…but i’ll work on that. My gut instinct is that the ‘got focus’ events are firing from LO form loading before user actually provides any input whatsoever. To me…got focus events should not apply to system housekeeping but rather only to actual user actions/input…

Could be you have to look at the ImplementationName.

Example:

SUB Eventsource(oEvent AS OBJECT)
DIM oForm AS OBJECT
oForm = oEvent.Source
MsgBox oForm.ImplementationName
END SUB

Often I get two events from forms. The implementation name will be
org.openoffice.comp.svx.FormController and
com.sun.star.comp.forms.ODatabaseForm.
But most of the time I need ODatabaseForm. So macros won’t run with FormController, but will run with ODatabaseForm.

You could just log them in an array, as you already have a global var.

That is interesting but definitely over my head. I just click ‘create form in design view’…then i add tables onto it. I guess the first is a FormController form and the table forms are of type ODatabaseForm…but really no idea. Could be dangerous to assume LO would know what i want…i’ll try to check on them…

yeah…actually i figured out the msgboxes require way too much clicking and started logging it all into really large multi-line text box. Still, its a lot of work mapping the route through the load sequence. 40 or 50 “here 1”, “here 2” etc. till up around 36 and looping back with repeats. Then, i don’t know if all of that is LO housekeeping or if some of it is actually my own initialization. MS Access did this same thing. I was hoping LO had an easy way to switch it off till my initialization was completed. Or maybe the on load and got focus events are just unpredictable…When a table loads the data in for display…does that trigger a record change event??? Even simple little things like that have to be known in advance. Well, i’ll keep plugging away till i find something that works most of the time.

Can not believe this… from the main menu->Form->Activation Order… Wow…just sitting right there! So this solved my problem. I just put a dummy text box on my main form and set it to be activated dead last. Then give it an event “When Receiving Focus” macro that kicks off all of my initialization with full assurance that all of the form(s) objects are all activated and ready to address. Super! Thanks! Even though i found the solution myself…just talking about it helped provide the motivation i needed to solve it.