How to create object in excel by javascript

Viewed 140

i wonder how to create shape object by javasript in excel. i know how to read js code in vba but have no idea how get handles to objects. below working addition example.

Public Sub TestJS()
    Dim script As New ScriptControl
    Dim result As Variant
    script.Language = "JScript"
    With script
        .AddCode "function add(a,b) {return 'result from '+a+' + '+b+' is ' +(a+b);}"
        result = .Run("add", 1, 2)
    End With
    
    Cells(1, 1) = result
End Sub

finally i try to run this code fragment in excel. js files and full code here

        PDF417.init(hub3_code);             

        var barcode = PDF417.getBarcodeArray();

        // block sizes (width and height) in pixels
        var bw = 2;
        var bh = 2;

        // create canvas element based on number of columns and rows in barcode
        var canvas = document.createElement('canvas');
        canvas.width = bw * barcode['num_cols'];
        canvas.height = bh * barcode['num_rows'];
        document.getElementById('barcode').appendChild(canvas);

        var ctx = canvas.getContext('2d');     

any advice are welcome

0 Answers
Related