Ask Your Question
0

Can't run JavaScript macros in LO

asked 2016-09-15 22:25:37 +0200

Kenneth Evans gravatar image

I just installed LO 64-bit on Windows 7.

I have an ODS file with a macro. I set Tools|Options|LibreOffice Security from High to Medium (allows unsigned macros). I also checked the box to enable macros when opening the spreadsheet. The macro does not not work and also the LibreOffice helloworld.js macro does not work.

The first gives the dialog:

A scripting Framework error occurred while running the JavaScript script DOSTLSummary.js.

Message: "com" is not defined.

(This is from the importClass(Packages.com.sun.star.uno.UnoRuntime); line at the tip of the macro.)

The second gives the dialog: A scripting Framework error occurred while running the JavaScript script helloworld.js Message: Cannot read property "getText" from null

This happened before installing a JRE via Tools|Options|Advanced. I have since installed a JRE it likes (apparently must be 64-bit). I still cannot run the above macros.

These macros work in OpenOffice. The UI for Tools|Macros seems similar to OO, down to the Rhino JavaScript debugger.

Is there something else I have to do or doesn't JavaScript work in LO. Or maybe I should install the 32-bit version of LO?

edit retag flag offensive close merge delete

Comments

If I knew how, I would revise the question. The error is actually not where I said but at the line:

  1. var weight = com.sun.star.awt.FontWeight.BOLD;

The macro works in OpenOffice and handles that line properly. So the question should simply be why doesn't it work in LibreOffice?

helloworld.js does not work in Calc. I didn't know that at the time. I have later got other macros to work, so the remaining questions are not relevant. Sorry, it was my first time using LibreOffice.

Kenneth Evans gravatar imageKenneth Evans ( 2016-09-29 23:51:39 +0200 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2016-09-30 00:38:12 +0200

Kenneth Evans gravatar image

updated 2016-09-30 00:41:42 +0200

(It says I can revise the question, but I don't see how to do that. I'm new to LibreOffice.)

It turns out the only problem was the line (and some others like it):

var weight = com.sun.star.awt.FontWeight.BOLD;

It is fixed by changing it to:

var weight = Packages.com.sun.star.awt.FontWeight.BOLD;

For the record, the macro was written in OpenOffice and runs Ok there.

edit flag offensive delete link more
0

answered 2016-09-16 08:39:56 +0200

karolus gravatar image

Hallo

The hello World.js-example is designed to work only from writer, not from calc

edit flag offensive delete link more

Comments

Thanks. There is no indication of that (like a comment in the script or something). It seemed like a logical thing to try when things weren't working, and you are new to the system. It turns out Javascript macros do work for me. It's just that this one fails (on a different line than I thought). I have clarified that in a comment to the original question.

Kenneth Evans gravatar imageKenneth Evans ( 2016-09-30 00:00:07 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-09-15 22:25:37 +0200

Seen: 815 times

Last updated: Sep 30 '16