Get Started
Plugins
Macros
More information

GetVBAMacros

GetVBAMacros() → { string | null }

Returns all VBA macros from the document.

Parameters:

This method doesn't have any parameters.

Returns:

Type
string | null

Example

Copy code
window.Asc.plugin.executeMethod("GetVBAMacros", null, function(data) {
    if (data && typeof data === 'string' && data.includes('') + 12;
            var end = el.indexOf('', start);
            var macros = el.slice(start, end);

            start = el.indexOf('Name="') + 6;
            end = el.indexOf('"', start);
            var name = el.slice(start, end);
            var index = Content.macrosArray.findIndex(function(macr){return macr.name == name});
            if (index == -1) {
                macros = macros.replace(/&/g,'&');
                macros = macros.replace(/</g,'<');
                macros = macros.replace(/>/g,'>');
                macros = macros.replace(/'/g,'\'');
                macros = macros.replace(/"/g,'"');
                macros = macros.replace(/Attribute [\w \.="\\]*/g,'');
                Content.macrosArray.push(
                    {
                        name: name,
                        value: '(function()\n{\n\t/* Enter your code here. */\n})();\n\n/*\nExecution of VBA commands does not support.\n' + macros + '*/',
                        guid: create_guid()
                    }
                );
            }
        });
    }
    updateMenu();
    window.CustomContextMenu.init();
    if (Content.current === -1)
    {
        let event = new Event("click");
        document.getElementById("button_new").dispatchEvent(event);
    }
});