You can assign custom scripts (macros) to menu items, icons, dialogue box controls, and events in Office.
Office internally supports the following scripting languages:
Office Basic
JavaScript
BeanShell
Python
In addition, developers can use high-level languages, for example Java programming language, to control Office externally. The API reference is online at api.libreoffice.org.
Choose Tools - Customise, and click the Menus tab.
Click Add.
In the Category list box, scroll down and open the "Application Macros" entry.
You see entries for "Application Macros" (scripts in the share directory of your Office installation), "My Macros" (scripts in the user directory), and the current document. Open any one of them to see the supported scripting languages.
Open any scripting language entry to see the available scripts. Select a script.
A list of the script functions appears in the Commands list box. Select a function.
Click Add to create a new menu assignment. The new menu entry appears in the Entries list box.
Choose Tools - Customise - Keyboard.
In the Category list box, scroll down and open the "Application Macros" entry.
You see entries for "Application Macros" (scripts in the share directory of your Office installation), "My Macros" (scripts in the user directory), and the current document. Open any one of them to see the supported scripting languages.
Open any scripting language entry to see the available scripts. Select any script.
A list of the script functions will appear in the Commands list box. Select any function.
Click the option button for Office or Writer (or whichever application is currently open).
Selecting the option button sets the scope of the new key combination to be applicable in all of Office or only in documents of the current module.
Choose Tools - Customise - Events.
Click Macro button.
In the Library list box, scroll down and open the "Application Macros" entry.
You see entries for "Application Macros" (scripts in the share directory of your Office installation), "My Macros" (scripts in the user directory), and the current document. Open any one of them to see the supported scripting languages.
Open any scripting language entry to see the available scripts. Select any script.
A list of the script functions will appear in the Assigned Action list box. Select any function.
Select to save in Office or current document.
This sets the scope of the new event assignment to be applicable in all of Office or only in documents of the current module.
Select the embedded object, for example a chart, in your document.
Choose Format - Frame and Object - Properties - Macro.
In the Macros list box, open the Office Scripts entry.
You see entries for share (scripts in the share directory of your Office installation), user (scripts in the user directory), and the current document. Open any one of them to see the supported scripting languages.
Open any scripting language entry to see the available scripts. Select any script.
A list of the script functions will appear in the Existing macros in list box. Select any function.
Select an event from the list and click OK.
Position the cursor inside the hyperlink.
Choose Insert - Hyperlink.
Click the Events button.
Select and assign as stated above.
Select the graphic in your document.
Choose Format - Image - Properties - Macro.
Select and assign as stated above.
Insert a form control, for example a button: Open the Form Controls toolbar, click the Push Button icon, drag open a button on your document.
With the form control selected, click Control on the Form Controls toolbar.
Click the Events tab of the Properties dialogue box.
Click one of the ... buttons to open a dialogue box in which you can assign a script to the selected event.
Open the Office Basic dialog editor, then create a dialogue box with a control on it.
Right-click the control, then choose Properties.
Click the Events tab of the Properties dialogue box.
Click one of the ... buttons to open a dialogue box in which you can assign a script to the selected event.