# Revision history [back]

The way to do this is to call a macro using the UNO construct getScript(sScriptURI) and then call the invoke method for the object. That is the easy part. The hard part is figuring out the sScriptURI, which is a universal location for the script. There is a paucity of documentation about what, exactly, this is.

By trial and error you may find that a sScriptURI for a Basic macro looks like this:

"vnd.sun.star.script:Standard.Module1.SubName?language=Basic&location=application"


You can see the different elements. By further trial and error, you may find that a Python macro call_me.py with a method of the same name (call_me) saved in the following location:

/home/user/.config/libreoffice/{LOversionnumber}/user/Scripts/python/


Is accessible as follows:

"vnd.sun.star.script:call_me.py$call_me?language=Python&location=user"  Thus, if I have the following Python macro at the above location saved as call_me.py: def call_me(*args ): return "call me"  Then if I invoke the following in Basic, it will return to the Basic macro the value set forth in the Python macro ("call me"): Dim a(0),b(0),c(0) As Variant scpr = ThisComponent.getScriptProvider scmod = scpr.getScript("vnd.sun.star.script:call_me.py$call_me?language=Python&location=user")

returnFromPython = scmod.invoke(a,b,c)
MsgBox returnFromPython


location=share also is a valid location, I think, depending on where, exactly, the script is saved. For documentation of what are the arrays a, b, c, see the API reference. To make your Python macro work, you may need to redefine those.