Search code examples
libreofficelibreoffice-writer

LibreOffice 5.1 Writer: insert script


In the previous versions of LibreOffice, one could insert script into an odt from "insert" menu.

According to official answer this feature was removed: https://ask.libreoffice.org/en/question/67576/menu-insert-script-removed/

How am I then supposed to insert script? What is "Writer HTML", which this answer is suggesting? I can't find a word about it anywhere else.

Am I forced to install earlier versions of LibreOffice just for this feature if I want to avoid digging through massive XMLs?

Also, can anyone explain the reason of that move (removing existing, convenient feature from the product)?


Solution

  • To create an HTML document in Writer (meant by "Writer HTML"), go to File -> New -> HTML Document, and then it will be possible to insert a script. Or, it sounds like you may want File -> New -> XML Form Document instead.

    It looks to me like Insert -> Script is useful only for adding Javascript or similar to a document, which seems appropriate for an HTML document or forms. So the new change makes sense to me.

    To write a Javascript macro, put the code in a text file under the LibreOffice user directory, as described here.

    EDIT:

    From the comment below, it sounds like you are inserting a directive for use with JODReports. Could you do the following instead:

    Insert a FreeMarker directive in OpenOffice.org Writer from the menu Insert / > Fields / Other... (or just press Ctrl+F2), then click on the Functions tab and > select Input field. Change the field Reference to JOOScript and in the > following field Content enter the directive (e.g. "[#assign title='Mr.']").

    Note: Apache OpenOffice still has Insert -> Script.