Worksheet.activate() freezes excel online. RRS feed

  • Question

  • I am trying to activate a created sheet but it is not working properly. I am trying following code snippet.

           var sheet = ctx.workbook.worksheets.add();



    If I execute the above code the excel online freezes.

    It shows the "Working on it" message on gray overlay screen.

    On the other hand if i change the code to,

           var sheet = ctx.workbook.worksheets.add();




    then it correctly activates the sheet.

    Why does the code freezes excel when created sheet is not synced?

    Tuesday, January 31, 2017 1:07 PM


  • Hi Ashfaq_P,

    >> Why does the code freezes excel when created sheet is not synced?

    It is caused by that ctx.workbook.worksheets.add() only add this new sheet in JavaScript proxy objects, ctx.sync() is used to synchronizes the state between JavaScript proxy objects and real objects in Excel. Before activating the worksheet, you need to sync the new worksheet to real objects in Excel.

    You could refer the link below for more information about sync().

    # Excel JavaScript API programming overview

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    • Marked as answer by Ashfaq_P Thursday, February 9, 2017 6:24 AM
    Thursday, February 2, 2017 5:04 AM