I am using two libraries in my .ods file: Standard and Custom. I have a LoadLibs macro in a module in the standard library that does an explicit load of the Custom library. The LoadLibs macro is set as the assigned action for the Open Document event on the .ods file.
The sheet in the .ods file has a cell that invokes a function macro (FM) that is defined in the Standard library. FM then invokes another function defined in the Custom library. When the Custom library is already loaded, all is fine and FM behaves as expected.
However, when opening the file, there is an error: “Basic runtime error. Sub-procedure or function procedure not defined”. When I click OK, the spreadsheet opens and I can see that the cells that called FM have incorrect values. When I press F9 to recalculate, they are not updated. When I press Ctrl-Shift-F9 to recalculate hard, they are updated with the expected values.
I tried the same setting the LoadLibs macro as the assigned action for the Document Loading Finished and Activate Document events as well, with the same [unexpected] result.
It seems that the Custom library is getting loaded (which I can verify in the Basic IDE after getting past the initial runtime error), but only after the cells in the sheet are calculated when the file is loaded.
How can I get the Custom library to be loaded before any calculations are done so I can avoid the error and the sheet has the proper values without needing to do a recalculate hard?