Getting started
Macros are small scripts used to facilitate your day-to-day routine work with different types of documents. ONLYOFFICE macros use the JavaScript syntax and Office JavaScript API scripting notation.
There are several reasons why ONLYOFFICE uses JavaScript for macros:
- cross-platform,
- easy to use,
- security, as macros do not have any access to the system. They are just JS code that runs in the same window with the editors.
Please note that starting from version 7.1, the access to the window and document objects and the alert function is restricted from the macros because the "use strict" mode was applied to the macro scripts. Don't forget to declare variables before using them so that the macros work correctly.
You can find ready-to-use macros here or create your own ones.
How to start writing your macro:
- Open the Plugins tab and click Macros.
- Consult the API documentation to write the script.
- Write code for your macro.
- To rename the macro, click next to the macro name and select Rename. Enter a new name for the macro and click Ok.
- When ready, click to run your code in the document.
To add more macros, click .
If you want to delete an unnecessary macro, click next to the macro name and select Delete.
You can also copy your macro. To do this, click next to the macro name and select Copy.