Getting Errors with Python and JavaScript Macros

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
Caused by: java.lang.NoSuchFieldException: uri
at java.lang.Class.getDeclaredFielod(Unknown Source)

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.

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).

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 ?

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

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

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

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

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