Get Started
Plugins
Macros
More information

SetMacros

SetMacros(data)

Sets macros to the document.

Parameters:

Name Type Description
data Macros

The Macros object containing the data about all the macros from the document.

Returns:

This method doesn't return any data.

Example

Copy code
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
    }
]);