Samples

The following examples will show you how to use ONLYOFFICE macros and compare the JavaScript code with Microsoft Visual Basic for Applications code so that you could see the difference and understand what can be done to convert the VBA code to ONLYOFFICE macros.

Write data to worksheet cell

In this example we are writing the data (the "Hello world" phrase) to fourth column of the third row of the worksheet.

More

Change cell background color

In this example we are seting the background color of the cell B3 to blue.

More

Change cell font color

In this example we are seting the font color of the cell B4 to red.

More

Make cell font bold

In this example we are seting the font of the cell A2 to bold.

More

Merge cell range

In this example we are merging selected cell range.

More

Unmerge cell range

In this example we are unmerging selected cell range.

More

Set column width

In this example we are setting the width for the second ("B") column.

More

Format range as table

In this example we are formatting the range of cells as a table.

More

Add chart

In this example we are creating the chart from the data in the "C5:D7" cell range.

More

Highlight duplicates

In this example we are highlighting duplicates in the selected area with different colors to recognize duplicated values quickly.

More

Next blank row

In this example we are finding the next available blank row in a worksheet.

More

Insert text

In this example we are inserting text into the document at the current cursor position.

More

Currency exchange rates

In this example we are returning information about the exchange rates for the last several days and fill in the table with the received values.

More

Import CSV/TXT data

In this example we are importing data from remote CSV/TXT files into the spreadsheet.

More

Recalculate worksheet values

This macro repeatedly recalculates worksheet cell values within one-second intervals.

More

Unhide all rows and columns

In this example we are unhiding all the rows and columns in a worksheet.

More

Remove shapes from slides

In this example we are removing shapes from the presentation.

More

Insert unique id

In this example we are inserting a unique id into a form document.

More

Complete address information

In this example we are completing address information in the spreadsheet.

More

Replace words in document

In this example we are replacing words in the text editor.

More

Support

If you want to request a feature or report a bug regarding macros, use the issues section on GitHub.

You can also request a macro sample by contacting us at marketing@onlyoffice.com.

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