Globalscope.BasicLibraries.LoadLibrary(<lib name>) etc. not working

I am working through examples from Andrew Pitonyak’s ‘AndrewPersonalLibs.odt’ and have hit a problem.

In library AndrewTestLib, module Module1 is a macro CopyLibToDoc. In this is a couple of lines of code designed to load a library which I have edited to ‘AndrewBase’:

sLName = "AndrewBase"
If (Not Globalscope.BasicLibraries.isLibraryLoaded(sLName)) Then
    Globalscope.BasicLibraries.LoadLibrary(sLName)
End If

The trouble is, this does not work for some reason.

As you can see from the MRI window, the only accessible libraries are from ‘My Macros & Dialogs’ and ‘LibreOffice Macros & Dialogs’. Any attempt to load any of the other libraries through code gives the same result: the library cannot be found, cannot be loaded etc.

Is there something I am missing?

Thanks,
Doug

You may find this useful: Accessing Libraries from Basic - Apache OpenOffice Wiki

GlobalScope doesn’t relate to open documents’ libraries. If you use a library from current document, you need to use BasicLibraries instead of Globalscope.BasicLibraries.

Thanks Mike - that solved it.
Why does the “Elements” list of oDocLibCont and oLibCont not list the library I have just loaded:

oDocLibCont = createUnoService(“com.sun.star.script.DocumentScriptLibraryContainer”)
subInspect(oDocLibCont)
oLibCont = createUnoService(“com.sun.star.script.ApplicationScriptLibraryContainer”)
subInspect(oLibCont)

Also, can I load the library of Document A from Document B?

As for second question - oDoc.BasicLibraries works for any opened oDoc.

See http://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1document_1_1XEmbeddedScripts.html

See http://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1document_1_1OfficeDocument.html

Excellent. Thanks Mike - I now have some more research to do - just love learning new stuff. ":sunglasses: