Ask Your Question

Getting Errors with Python and JavaScript Macros [closed]

asked 2015-07-22 16:35:16 +0200

peterwt gravatar image

updated 2020-08-23 09:11:24 +0200

Alex Kemp gravatar image

Using LO on Windows 8.
Looking at the Python and JavaScript Macros supplied with the distribution. Using Writer document with button.
Using the Macro Selector RUN works ok. When this Macro is assigned to the button click get this error :- during invoking function HelloWorldPython in module file:///C:/Prograrn%20Files%20(x86)/Libre0ffice %204/share/Scripts/python/ (< class 'TypeError' >: HelloWorldPython0 takes 0 positional arguments but 1 was given

C:\Program Files (x86)\Libre0ffice 4\program\ in function
invokeO [ret : self.func( *args )] )

I would have thought that these operations are the same but what is the argument error that is shown above? How can this Macro be run from the button?
Running hellowworld.js directly gives this error :-
’, [jni_uno bridge error] UNO calling Java method getPropertyValue: non-UNO exception occurred: java.lang.RuntimeException: java.lang.NoSuchFieldException: uri java stack trace: java.lang.RuntimeException:java.lang.NoSuchFieldException: uri at at Caused by: java.lang.NoSuchFieldException: uri at java.lang.Class.getDeclaredFielod(Unknown Source) at

1 more
What does this all mean? How can a JavaScript Macro be run? Also if trying to assign this macro to the button it is not shown in the list of Macros.
I thought that as these Macros are supplied with the distribution they would work.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-08-23 09:11:39.016232

2 Answers

Sort by » oldest newest most voted

answered 2015-07-25 05:12:17 +0200

doug gravatar image

When you use a button to activate a macro, LO sends the macro an argument consisting of an event object. The parents of the event object are the button and the form, in some combination of methods and properties which can be useful in handling macros.

Python or PyUNO apparently needs to handle the arguments explicitly, and if they are not handled it will raise an error as you state. This is a trivial matter of adding into the parentheses at the beginning *args as in def HelloWorldPython(*args ): Now the function will handle the arguments if they are supplied.

As for the java script, I cannot replicate your experience, the .js script works both directly and from the command button and I do not see anything in the script that would generate the error noted (although I don't know much about java).

(if this answers your question, please accept the answer by clicking the check mark (image description) to the left).

edit flag offensive delete link more

answered 2015-07-27 16:41:58 +0200

peterwt gravatar image

updated 2015-07-27 16:51:45 +0200

Thanks @doug. have got the Python working.

The problem on JavaScript is a bug on some versions of LO. Have seen this bug reported in another Forum.

What version of LO are you using @doug ?

edit flag offensive delete link more


LO rc3 (dev), Linux OpenSuse 13.2 / KDE 4.

doug gravatar imagedoug ( 2015-07-28 13:39:31 +0200 )edit

@doug: 5.0.0 RC4 has been out for some days by now.

rautamiekka gravatar imagerautamiekka ( 2015-07-28 17:41:42 +0200 )edit

Takes a little while for them to be pushed to the OpenSuse LO:Factory repository....

doug gravatar imagedoug ( 2015-07-28 17:48:32 +0200 )edit

@doug: Addendum: and there's no such thing as rc3.

rautamiekka gravatar imagerautamiekka ( 2015-07-28 18:03:28 +0200 )edit

Thank you @rautamiekka. It is which is 5.0.0 rc3. So very very technically, you are right.

doug gravatar imagedoug ( 2015-07-28 22:42:58 +0200 )edit

Question Tools

1 follower


Asked: 2015-07-22 16:35:16 +0200

Seen: 991 times

Last updated: Jul 27 '15