The last line of this basic Python script inspired by the official doc https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/sf_calc.html ################################################ import sys PATH = '/usr/lib/libreoffice/program/' if PATH not in sys.path: sys.path.append(PATH) from scriptforge import CreateScriptService doc = CreateScriptService("Calc") ################################################ produces this error: ################################################ Traceback (most recent call last): File "/test.py", line 8, in <module> doc = CreateScriptService("Calc") ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/libreoffice/program/scriptforge.py", line 2992, in CreateScriptService ScriptForge() File "/usr/lib/libreoffice/program/scriptforge.py", line 73, in __call__ cls.instances[cls] = super(_Singleton, cls).__call__(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/libreoffice/program/scriptforge.py", line 150, in __init__ ScriptForge.scriptprovider = self.ScriptProvider(self.componentcontext) # ...script.provider.XScriptProvider ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/libreoffice/program/scriptforge.py", line 199, in ScriptProvider return masterscript.createScriptProvider("") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'createScriptProvider' ################################################ This is my first bug report, sorry if my report is not ideal.
Are you running this script from within a document? If so, I recommend you create a function and make it available as a script. To do this, follow the example "Creating Python script files" in the following help page: https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/sf_intro.html It would be something like: from scriptforge import CreateScriptService # This is your macro def my_script(args=None): doc = CreateScriptService("Calc") # Here you can do whatever you want with 'doc' # Here you make the macro available g_exportedScripts = (my_script, ) Now you can go to Tools - Macros - Run Macro. Under "My Macros", search the module you've just created (it will be the name of the Python file without the .py), and then you can select 'my_macro' and run it.
It seems we can close this per the last comment.