When the LO program starts up it loads the Library Standard in My Macros. As you have created another Library General containing foo this Macro can not be found as the Library General has not been loaded. You need to explicitly load the General Library using -
Sub LoadLib
GlobalScope.BasicLibraries.loadLibrary("General")
End Sub
Similarly if you have Macros in your database document (myfile.ods) they should be in the Standard Library as this Library is loaded when you open the document. If you create another Library in your database document then you will need to load this explicitly too.
If you put the Macro Sub LoadLib above in the Standard Module of your document you can have this execute when you open the document by having it run from the “Open Document” event for the document.
Also if you are having more than one Module being loaded make sure you do not use the same name for a Macro in both Modules as it will obviously crease a conflict in names.