November 14, 2024
Author: Alina
As we continue to iterate and enhance the editor, we strive to provide users with customized solutions to meet their specific needs. ONLYOFFICE macros are one of these powerful customization tools. In this article, we attachEvent method will introduce the attachEvent method and explain how it works with macro code events, as well as provide a script example that runs two independent macros in one execution.
Use the attachEvent method to handle events in your macro code
About the attachEvent method
This method listens for a specific event and once the event is triggered, calls the callback function, allowing us to execute additional scripts in the callback. The following is an example of using the onWorksheetChange event:
Use the attachEvent method to malaysia whatsapp number data execute two macros in one run
The first part of the attachEvent method script will use the Import CSV macro to read data from an external CSV file and import it into the table. The second part, which is executed in the callback function, is responsible for calculating the sum of a specific column and displaying the result.
So, first we import the external CSV file and fill the table with data:
Then, introduce the attachEvent method calculateSum() function to calculate the sum of the values in the selected range:
Next, we call the LoadFile function and execute the attachEvent method to listen for any changes on the worksheet. Once a change is detected, the calculateSum() function will be triggered and executed in the callback:
At the end of the macro, we call the asc_calculate function to reload the spreadsheet and display the calculation results in the selected cell:
At ONLYOFFICE, we are always striving
To improve the flexibility afb directory and versatility of our products. ONLYOFFICE macros are a great tool that allows you to customize functionality to meet specific needs. Our rich, continuously updated API library will help you create your own solutions.
We invite you country wise email marketing data to use this attachEvent method resource to create your own macros. If you have any questions or a macro you would like to share, please feel free to contact us. We look forward to working with you.