2

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

  • Why do you want to insert script into an .odt file? Are you making a web page, or perhaps creating a macro? – Jim K Apr 28 '16 at 20:28

2 Answers2

5

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.

Jim K
  • 12,824
  • 2
  • 22
  • 51
  • 1
    Well, my firm uses hundreds of .odt files with JOOScripts serving as templates. Inserting script in standard editor was very convenient, so ultimately I ended up installing earlier version of LibreOffice. Thanks for your input though. – NoMercyIncluded May 04 '16 at 15:45
  • Ow, that is what I seek. Looks like we were doing it the wrong way then all the time, mixing script and input fields. This exhausts the question, thanks! – NoMercyIncluded May 05 '16 at 08:51
2

The script functionnality is still there. It's just not in the default menus. Go to Scripting LibreOffice for adding it back to the Insert menu items.

Here is one way to add it back (done with Version: 5.3.2.2) :

  1. Choose Tools - Customize, and click the Menus tab.
  2. In LibreOffice Writer Menus, scroll down to Insert.
  3. In Menu Content - Entries, scroll down to any item after which you want the Script item to appear.
  4. Click Add Commands.
  5. In the Category list box, choose All catgories.
  6. In the Commands list box, scroll down to Script
  7. Click Add to create a new menu item. The new menu entry appears in the Entries list box.
  8. Click OK and you are ready to insert a new script object anywhere.
Dominique Fortin
  • 2,212
  • 15
  • 20