Class Basic

class ooodev.macro.script.Basic[source]

Class for managing Basic script.

New in version 0.38.0.

static get_basic_script(macro='Main', module='Module1', library='Standard', embedded=False)[source]

Grab Basic script object before invocation.

  • macro (str, optional) – Macro name. Defaults to “Main”.

  • module (str, optional) – Module name. Defaults to “Module1”.

  • library (str, optional) – Library name. Defaults to “Standard”.

  • embedded (bool, optional) – If True, the script is embedded in the document. Defaults to False.


Basic script object.

Return type:



The invoke method args:

  • the first lists the arguments of the called routine

  • the second identifies modified arguments

  • the third stores the return values

>>> def r_trim(input: str, remove: str = " ") -> str:
...     script = Basic.get_basic_script(macro="RTrimStr", module="Strings", library="Tools", embedded=False)
...     res = script.invoke((input, remove), (), ())
...     return res[0]
>>> result = r_trim("hello ")
>>> assert result == "hello"

See also

LibreOffice - Calling Basic Macros from Python