Can't run JavaScript macros in LO

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?

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.

Hallo

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

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.

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