Is it possible to automatically run a macro immediately after loading a document? I tried Sheet Events → Activate Document, it doesn’t work : I must click another sheet, then return to the first sheet, and only then macros starts. LO 6.3.6.2, Windows 10.
Depending on what services your macro uses, it may need to wait for onViewCreated
.
The sequence of events when opening Calc document is not easy to remember:
OnLoadFinished
, OnTitleChanged
, OnFocus
, OnViewCreated
, OnLoad
.
When creating a new document:
OnCreate
, OnStorageChanged
, OnTitleChanged
, OnFocus
, OnViewCreated
, OnNew
.
I wonder who had the idea that OnLoadFinished should be earlier than OnLoad?
See 46484 – Notify new events OnCreate and OnLoadFinished
Two new document events are available now, their API names are “OnCreate” (for
new, empty documents) and “OnLoadFinished” (for documents loaded from a file or
stream). They are sent by every document, regardless if it is opened/created
with or without a view, hidden or visible.
OTOH the “old”, well known events “OnNew” and “OnLoad” are sent only for visible
documents and they are sent not before the document has become visible.
Bah, probably should be the Document loading finished event (OnLoadFinished
is the routine name).
@erAck, I am impressed by your erudition!
However, now the sequence of events (beginning to end) received by the listener is the same as in my previous post.