Description: 1) Start LibreOffice 2) Open new Writer document 3) Type some text 4) Macros > Run > Select the Insert Text python script 5) Click on Run. 6) Error message: com.sun.star.uno.RuntimeException: Error during invoking function InsertText in module file:///Applications/LibreOffice.app/Contents/Resources/Scripts/python/InsertText.py (<class 'TypeError'>: InsertText() missing 1 required positional argument: 'text' File "/Applications/LibreOffice.app/Contents/Resources/pythonscript.py", line 915, in invoke ret = self.func( *args ) ) Steps to Reproduce: See above Actual Results: Script fails to execute, displays error message Expected Results: Script should execute and insert text. Reproducible: Always User Profile Reset: Yes Additional Info: Version: 7.3.6.2 / LibreOffice Community Build ID: c28ca90fd6e1a19e189fc16c05f8f8924961e12e CPU threads: 8; OS: Mac OS X 12.6; UI render: default; VCL: osx Locale: fr-FR (fr_FR.UTF-8); UI: fr-FR Calc: threaded from macOS appstore, if that makes any difference (Arm M1)
Repro with Version: 7.3.6.2 / LibreOffice Community Build ID: 30(Build:2) CPU threads: 12; OS: Linux 5.15; UI render: default; VCL: kf5 (cairo+xcb) Locale: pt-BR (pt_BR.UTF-8); UI: en-US Ubuntu package version: 1:7.3.6-0ubuntu0.22.04.1 Calc: threaded Indeed the macro does not work even in a new LO installation.
TBH I really don't know why this macro is even accessible via Toos - Macros - Run Macro, because it requires a positional "text" argument to work. See: https://opengrok.libreoffice.org/xref/core/scripting/examples/python/InsertText.py So it seems the "InsertText" function is meant to be called by other scripts only and not as a standalone script. For instance, create a Writer document and open an APSO Python shell. Now type: from InsertText import InsertText InsertText("Hello") The code above will insert "Hello" where your cursor is located. The only weird thing is that the InsertText macro should not be reachable via the Run Macro menu. The script isn't even exported using g_exportedScripts, so I don't see why it is listed to the user.
A simple fix is to add the following line at the end of InsertText.py. g_exportedScripts = () This would make the script no longer appear in the Run Macro dialog. And it would still work when called from another macro, as in the example I gave in Comment #2. Let's leave this as UNCONFIRMED for now to see if anyone else has other ideas on this matter.
Rafael Lima committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/84e9a0056967d5c641ec63bf6a4dc6c0f2798e3d tdf#151076 Create callable Python script using InsertText It will be available in 7.5.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.