Get Started
Plugins
Macros
More information

window.Asc.plugin.executeMethod ("SetMacros", [args], callback)

Description

Defines the method that allows setting macros to the document.

Usage

This method should be used in the following way:

window.Asc.plugin.executeMethod ("SetMacros", [data]);
Parameters
Parameter Description Type Example
data The Macros object containing the data about all the macros from the document in the following form (JSON):
  • macrosArray - an array of macros codes ([{"name": "Macros1", "value": "{macrosCode}"}]),
    type: array of objects;
  • current - a current macros index,
    type: number,
    example: 1.
object
Returns

The method returns the undefined value.

Example
window.Asc.plugin.executeMethod("SetMacros", [{"macrosArray": [{"name": "Macros 1","value": "(function()\n{oDocument = Api.GetDocument();\noParagraph = Api.CreateParagraph();\noParagraph.AddText(\"This is a new paragraph\");\noDocument.Push(oParagraph);\n})();"},{"name": "Macros 2","value": "(function()\n{oDocument = Api.GetDocument();\noParagraph = oDocument.GetElement(0);\noParagraph.AddText(\"ONLYOFFICE Document Builder\");\noRange = oDocument.GetRange(0, 24);\noRange.SetBold(true);\n})();"}],"current": 1}]);