BASIC Calc: How to work with various Libraries?

There are 2 error messages:

image description

0003.ods

firebird4ask.odb

What was wrong with the code ?

Only library Standard is load by default, others libraries you need load in memory before used:

Sub any_sub()
Globalscope.BasicLibraries.LoadLibrary("Library2")


End Sub

Hello,

These errors are related. The first is because ConnectDatabase is not accessible & the second because in the error routine DisconnectDatabase is also not accessible. You already have the answer (see → Calc BASIC | How to call Function in other Library ?. You just need to add:

If Not BasicLibraries.isLibraryLoaded("Library2") then
    BasicLibraries.loadLibrary("Library2")
Endif

before line #7 - the call to ConnectDatabase

Keep this in mind when initially calling TestConnectDatabase1. Library1 needs to be loaded. Probably do both when opening the Calc file. Just put a sub in the Standard library to load both and attach to Open Document event.