window.Asc.plugin.executeMethod ("SetMacros", [args], callback)
Defines the method that allows setting macros to the document.
This method should be used in the following way:
window.Asc.plugin.executeMethod ("SetMacros", [data]);
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 macro index,
type: number,
example: 1.
|
object |
|
The method returns the undefined value.
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}]);