Reputation: 4521
Is there any way to store a key/value pair in the Word client using the JS APIs which will be applicable to other documents as well? Something like the roamingSettings
property which is available for Outlook APIs?
Upvotes: 2
Views: 151
Reputation: 219
Unfortunately Office does not provide any option to save user settings for all documents. Instead you can save settings for one document.
In your case you should use cookies. Second option is if you can have a json file to save data.
I am working on a word add-in developed with an express.js server. I save user specific data in a json file. My client javascript file sends ajax requests to server to retrieve data and to store new data.
Upvotes: 1
Reputation: 6957
The following are options offered by Office.js API to persist values:
Use members of the JavaScript API for Office that store data as either:
Use techniques provided by the underlying browser control: browser cookies, or HTML5 web storage (localStorage or sessionStorage).
In your case the best bet would be cookie
or localStorage
.
Reference article: Persisting add-in state and settings
Reference for project example on github: OfficeDev/Excel-Add-in-JavaScript-PersistCustomSettings
Upvotes: 3