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:

  1. Open the Plugins tab and click Macros.
  2. Consult the API documentation to write the script.
  3. Write code for your macro.
  4. To rename the macro, click Dots icon next to the macro name and select Rename. Enter a new name for the macro and click Ok.
  5. When ready, click Play icon to run your code in the document.

Macros window

To add more macros, click Plus icon.

If you want to delete an unnecessary macro, click Dots icon next to the macro name and select Delete.

You can also copy your macro. To do this, click Dots icon next to the macro name and select Copy.

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).