Macro 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 font and background color and make font bold

In this example we are setting the font to bold, change its color and cell background color

More

Merge and unmerge selected cell range

In this example we are merging one cell range and unmerge the other one

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 new chart for the selected cell range

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

More