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

TypeMandatory field

Parameters






ContextContext for working with a tabular document via ONLYOFFICE.Robin.OnlyOfficeCellYes
Macro Path

Path to the js file that contains the JS code for the macro

Acceptable file extension: .js

Robin.FilePathYes
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

  • The field does not need to be filled in if there are no input parameters in the macro
  • The field must be filled in if there are input parameters in the macro
  • There must be exactly as many elements in the collection as there are input parameters in the macro. Elements containing parameter values must be listed in the same order in which the corresponding 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

  • Since the types in Onlyoffice do not coincide with our types, for correct conversion of the macro result it is necessary to specify what type of data we expect to get
  • Field in the form of a dropdown list
  • Available list values:
    • String
    • Number
    • Collection
    • Table
    • Macro with no result
  • Default value - "Macro with no result"
  • If the result of the macro is a collection or a table, the action will return them as a collection of rows or a table with string values, respectively
  • The action will not terminate with an error if "Macro with no result" is selected and the action returns a result
Robin.StringNo

Results

ResultThe value returned by the running macro. If the macro returns nothing, the result will be emptyRobin.Object

Special conditions of use

  1. 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 hereOpen (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.

 

  • Нет меток