Run external macro Version 1 (Python)
Action group: ONLYOFFICE
Description
The action launches a macro in the document, JS-code of which is specified in a separate file.
The ONLYOFFICE application must be installed to work with the action.
The action runs a macro specified in a separate .js file. The language in which the macro is written must be JavaScript.
Examples of macros - https://api.onlyoffice.com/plugin/macrosamples/
You can familiarize yourself with the operation of the ONLYOFFICE Table Editor application in the User Manual.
Action icon
Settings of parameters
Name | Description | Type | Mandatory field | |
---|---|---|---|---|
Parameters | Context | Context for working with a tabular document via ONLYOFFICE. | Robin.OnlyOfficeCell | Yes |
Macro Path | Path to the js file that contains the JS code for the macro Acceptable file extension: .js | Robin.FilePath | Yes | |
Parameters | Values for macro input parameters. Parameter values should be specified in the collection in the same order in which these parameters are listed in the macro code
| Robin.Collection | No | |
Result type | The type of data that the macro should return as a result of its operation. If the macro does not return a result, this field can be left blank
| Robin.String | No | |
Results | Result | The value returned by the running macro. If the macro returns nothing, the result will be empty | Robin.Object |
Special conditions of use
- When running ONLYOFFICE actions, the document must be closed.
2. File extensions that the action can open: .xlsx, .xls, ods.
3. For correct start of actions when working with actions of ONLYOFFICE group of Windows OS it is necessary to add ONLYOFFICE plugin.
4. Realization of the full cycle of work with the table should contain all 4 actions of the Table Editor - "Open" - to start working with the file, "Run external macro". - to make changes, "Save" - to save changes and "Close" at the end of work with the file.
Example of use
Option 1
Task
There is a tabular document: "Book 1.xlsx". It is necessary to open this document in ONLYOFFICE and make changes using an external macro.
Solution
When running ONLYOFFICE actions, the document must be closed.
In order to open a document it is necessary to build and run the robot, having filled in its parameters beforehand.
If we want to make changes to an open file, we must first run the "Run external macro" action, make changes to the file and run the Save (ONLYOFFICE) action.
Therefore, the example implementation will contain all 4 actions. The red dot is a breakpoint, i.e. the robot will enter the stop mode at the action we set it to. To continue, it will be necessary to click the "Start" button.
Implementation
1. Open the ONLYOFFICE action group.
2. Assemble a robot scheme consisting of actions:
3. Move the "Open" action to the Studio workspace, having previously placed the file to load in one of the folders on your computer.
4. Set the parameters of the "Open" action by specifying the path to the file. You can see more details here: Open (ONLYOFFICE)
5. Set the parameters of the "Run external macro" action.
This is to:
a. Create a folder on your computer where the macros and the source file will be placed.
b. Consecutively fill in the fields "Context" (1), "Macro Path" (2), "Parameters"(3), "Result type"(4).
- in the "Macro Path" parameter specify the path to the folder where the macro is placed
- in the "Parameters" parameter specify the number of records and specify their value, if necessary
-
- in the "Result type" parameter, check the selected type in the dropdown list
6. In order to close the file with changes, you need to use the "Save" and "Close" actions in sequence.
7. To do this, you must click on the Save (ONLYOFFICE) action on the scheme, and fill in the Parameters field for this action.
6. Set the parameters of the action Close (ONLYOFFICE)
7. Launch the robot using the "Start" button in the top panel.
Result
The program robot completed successfully.
Option 2
Task
There is a tabular document: "Book 1.xlsx". It is necessary to open this document in ONLYOFFICE and make changes using an external macro without parameters
Solution
When running ONLYOFFICE actions, the document must be closed.
In order to open a document it is necessary to build and run the robot, having filled in its parameters beforehand.
If we want to make changes to an open file, we must first run the action "Run external macro", make changes to the file and run the action
Therefore, the example implementation will contain all 4 actions. The red dot is a breakpoint, i.e. the robot will go to the stop mode on the action on which we put it. To continue, it will be necessary to press the "Start" button.
Implementation
1. Open the ONLYOFFICE action group.
2. Assemble a robot scheme consisting of actions:
3. Move the "Open" action to the Studio workspace, having previously placed the file to load in one of the folders on your computer.
4. Set the parameters of the "Open" action by specifying the path to the file. You can see more details here: Open (ONLYOFFICE)
5. Set the parameters of the "Run external macro" action.
This is to:
a. Create a folder on your computer where the macros and the source file will be placed.
b. Consecutively fill in the fields "Context" (1), "Macro Path" (2), "Parameters"(3), "Result type"(4).
- in the "Macro Path" parameter specify the path to the folder where the macro is placed
- in the "Result type" parameter, check the selected type in the dropdown list.
6. In order to close the file with changes, you need to use the "Save" and "Close" actions in sequence.
7. To do this, you must click on the Save (ONLYOFFICE) action on the scheme, and fill in the Parameters field for this action.
6. Set the parameters of the action Close (ONLYOFFICE)
7. Launch the robot using the "Start" button in the top panel.
Result
The program robot completed successfully.