Created attachment 168728 [details] File with the Basic code described in the bug report Hi! Help pages about Basic libraries state that the library must be loaded by placing the GlobalScope.BasicLibraries.LoadLibrary("Library Name") statement before the first macro in the module. For example, the Help page for the Tools Library says: "This library must be loaded before execution. Place the following statement before the first macro in your module: GlobalScope.BasicLibraries.LoadLibrary("Tools")" Link: https://help.libreoffice.org/7.1/en-US/text/sbasic/shared/03/lib_tools.html?DbPAR=BASIC#bm_id491529070339774 The problem is that these instructions don't seem correct. If I create a new module in the Standard library of a new file and enter the following code (see that the library is loaded before the first macro): ---------------- GlobalScope.BasicLibraries.LoadLibrary("Tools") Sub Main 'Just some random code to showcase the error MsgBox "Hello" End Sub ---------------- Now, if I run the Main macro, I get the error message "BASIC syntax error. Expected: Sub." However, if I place the LoadLibrary statement inside the Sub, everything works fine. I am reporting this because this issue is either a bug in the Basic interpreter or it is something that needs fixing in the Help pages. I attached a ODS file with the example above for testing.
This bug was fixed by the following patch: https://gerrit.libreoffice.org/c/help/+/110366 Among other things, this patch changed the message explaining how to load libraries. The message now provides correct instructions.