Discover Word Online as a host inside Office add-ins

I use the Settings JavaScript API object in the Taskbar application to save several key-value pairs in a document.

My code is like this

 Office.context.document.settings.set(key, value);
 Office.context.document.settings.saveAsync(function () {
        Toast.showToast("Setting saved", "Info saved into the document using saveAsync");
 });

I also call a function saveAsyncon it to store the value.

The problem I am facing is that the settings are not saved in Word Online as the current settings. Object is not supported inWord Online

So, there is a way to find that the application is running in Word Online, so a message may be displayed, or localStorage or something else can be used to store the values.

Change . Created a publish request to add this to Word Online, you can support this feature here

Edit 2

To better explain the problem and share an example, I created an add-on sample, the manifest is located here .

Here you can enter a value for the key testand click save, this internally calls the function saveToPropertyBag(key, value)located at StorageLibrary.js. This function has the above code to save the setting, and then saveAsyncis called so that the values ​​are saved in the document.

Now you can update the browser or restart the addon and press get, the value will be available in Excel and Powerpoint, but not in Word Online.

, (Word Online), , , , .

+4
1

. (, Office)

,

if (Office.context.requirements.isSetSupported("Settings", 1.1)) {
    // Use Office settings
} else {
    // Fall back to local storage or something else.
}

~
    Office, MSFT

+2

Source: https://habr.com/ru/post/1613230/


All Articles