Search code examples
exceloffice-jsoffice-addinsexcel-addins

How to uniquely identify a work book in excel


We have an excel add in with user roles based functionalities. We have an idea of creating a sample workbook with all the feature access for demo purpose. Do we have any unique identifiers for workbooks in excel ? If exists how can we access them using officejs. We did a research in officejs documentation and found out that Worksheets inside a workbook has unique identifiers. The disadvantage is that these id will be reused when the worksheet is deleted and new worksheet is created.

Reference link of worksheet documentation .


Solution

  • Please try the following Officejs API to save a UDID along with the workbook. This will be persisted with the workbook.

    Office.context.document.settings.set("Worksheet_ID", 'your_unique_identifier''); Office.context.document.settings.saveAsync();

    Reference link - https://learn.microsoft.com/en-us/javascript/api/office/office.settings?view=word-js-preview#saveasync-options--callback-