0

I'm writing an MS Excel add-in. And I need to do some actions trough all selected sheets in a workbook. The problem is... I can't find any API that allows me to get access of selected sheets in the documentation. Neither for sheet collections, not workbook, or property of sheet.

What I need is:

Excel.run(async (context) => {
  const { worksheets } = context.workbook;
  worksheets.load('name');      
  await context.sync();

  worksheets.items.forEach((ws) => {
    if (ws.IS_SELECTED) {
      // do staff here
    }
  });
});

I need this IS_SELECTED property.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • 1
    Maxym, I checked the documentation for the Worksheet class and there there isn't a property that you can use to check whether a paricular worksheet is selected. I suggest that you log a feature request on the Microsoft 365 Developer community site. Worksheet class: https://learn.microsoft.com/en-us/javascript/api/excel/excel.worksheet?view=excel-js-preview#properties Microsoft 365 Developer community site: https://techcommunity.microsoft.com/t5/microsoft-365-developer-platform/idb-p/Microsoft365DeveloperPlatform – Jakob Nielsen-MSFT Oct 21 '22 at 16:35
  • Maybe there exists another way. For example, when I select several sheets, Excel changes the name of the document and adds [group] to it: Book1 - Excel -> Book1 [Group] - Excel. And maybe there exists some method that can return this group of sheets? But again, I can't find any way for this either for the workbook or for worksheets. – Maxym Marchenko Oct 24 '22 at 07:08

1 Answers1

1

The Office JavaScript API library (OfficeJS) doesn't provide anything for that.

You can post or vote for an existing feature request on Tech Community where they are considered when the Office dev team go through the planning process. Use the github label: Type: product feature request at https://aka.ms/M365dev-suggestions .

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45