none
With Office 2013 Javascript API, How to get activated Sheet Name ? RRS feed

  • Question

  • With below I can get activated sheet name , but it only work in Office 2016 , How to get activated Sheet Name with javascript API in Office 2013 ?

    Excel.run((context) => {
                        var sheet = context.workbook.worksheets.getActiveWorksheet();
                        sheet.load("name");
                        return context.sync().then(() => {
                            console.log(sheet.name);
                        });
                    })


    • Edited by Zhu Fucheng Tuesday, January 23, 2018 1:30 AM
    Thursday, January 18, 2018 8:45 AM

All replies

  • Hello Zhu Fucheng,

    Please try to refer to below code.

     function ShowActivatedSheetName() {
            Excel.run(function (ctx) {
                var worksheet = ctx.workbook.worksheets.getActiveWorksheet();
                worksheet.load('name')
                return ctx.sync().then(function () {
                    console.log("Activated sheet name is : "+worksheet.name);
                });
            }).catch(function (error) {
                console.log("Error: " + error);
                if (error instanceof OfficeExtension.Error) {
                    console.log("Debug info: " + JSON.stringify(error.debugInfo));
                }
            });
        }

    Best Regards,

    Terry


    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 MSDNFSF@microsoft.com.

    Monday, January 22, 2018 8:17 AM
  • Terry,

    It is work in Office 2016, but it does't work in office 2013.

    Best Regards

    Fucheng Zhu

    Tuesday, January 23, 2018 12:47 AM
  • Hello Zhu Fucheng,

    Sorry for my mistake. As far as I know, Excel JavaScript API does not support this property/function for Excel 2013 at present. If you want it also support for Office 2013, you can try to submit the feedback here.

    Thanks for understanding.

    Best Regards,

    Terry


    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 MSDNFSF@microsoft.com.

    Tuesday, January 23, 2018 8:52 AM
  • Thanks Terry.
    Wednesday, January 24, 2018 2:34 AM
  • Hello Zhu Fucheng,

    You are welcome. If you have any other office development issue, please feel free to post threads to let us know.

    Best Regards,

    Tery


    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 MSDNFSF@microsoft.com.

    Wednesday, January 24, 2018 10:03 AM