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.
Change cell background color
In this example we are seting the background color of the cell B3 to blue.
Change cell font color
In this example we are seting the font color of the cell B4 to red.
Make cell font bold
In this example we are seting the font of the cell A2 to bold.
Merge cell range
In this example we are merging selected cell range.
Unmerge cell range
In this example we are unmerging selected cell range.
Set column width
In this example we are setting the width for the second ("B") column.
Format range as table
In this example we are formatting the range of cells as a table.
Add chart
In this example we are creating the chart from the data in the "C5:D7" cell range.
Highlight duplicates
In this example we are highlighting duplicates in the selected area with different colors to recognize duplicated values quickly.
Next blank row
In this example we are finding the next available blank row in a worksheet.
Insert text
In this example we are inserting text into the document at the current cursor position.
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.
Import CSV/TXT data
In this example we are importing data from remote CSV/TXT files into the spreadsheet.
Recalculate worksheet values
This macro repeatedly recalculates worksheet cell values within one-second intervals.
Unhide all rows and columns
In this example we are unhiding all the rows and columns in a worksheet.
Remove shapes from slides
In this example we are removing shapes from the presentation.
Insert unique id
In this example we are inserting a unique id into a form document.
Complete address information
In this example we are completing address information in the spreadsheet.
Replace words in document
In this example we are replacing words in the text editor.
Add comments and change cell colors in spreadsheet
In this example we are adding comments and changing the background colors of selected cells.
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.