Search code examples
exceloffice-jsoffice-addinsexcel-2016excel-addins

Excel Desktop - Office.context.document.settings.get() didn't working


When the excel file is reopened then it did not persist the saved settings. I am able to do Office.context.document.settings.set('key', value). But when I try to get settings using Office.context.document.settings.get() it didn't working.

I want the state should be saved and the next time when we open the document we should retrieve the saved values

I am using Excel 2016 standard version Build Version - (16.0.4266.1001) 64 bit


Solution

  • You need to call the saveAsync method of the Office.Settings interface to persist the in-memory copy of the settings property bag in the document.

    Any settings previously saved by an add-in are loaded when it is initialized, so during the lifetime of the session you can just use the set and get methods to work with the in-memory copy of the settings property bag. When you want to persist the settings so that they are available the next time the add-in is used, use the saveAsync method.