Getting started with macros
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.
- Click New in the appeared window.
- Consult the API documentation to write the script.
- Write code for your macro.
- Rename your macro by clicking the corresponding button.
- When ready, click Run to run your code in the document.
If you want to delete an unnecessary macro, click the Delete button.