Office.EventType.DocumentSelectionChanged (in Excel), not working in all web browsers

Code sample

I am trying to add an event descriptor DocumentSelectionChangedto an online Excel document (checked in all browsers). This event has been created since the last 15 days.

Please help me here.

PS: The same event works fine in Excel 2013 desktop environment

 Office.context.document.addHandlerAsync(Office.EventType.DocumentSelectionChanged, function(eventArgs) {
     console.log(eventArgs);
 }, function(asyncResult) {
     console.log(asyncResult);
 });

OSF.DDA.AsyncResult {value: undefined, status: "failed", error: error OSF.DDA.Error}: OSF.DDA.Errorcode: 5001message: "An internal error has occurred." name: Internal error " Proto : OSF.DDA.Errorconstructor: (n, t, i) proto : Objectstatus:" failed "value: undefined__proto__: OSF.DDA.AsyncResultconstructor: (n, t) proto : object

http://aka.ms/R2yi5b

+2
2

. , , -. .

Cheers,

+1

(6 2015 , ):

, Excel Online, . ​​ , ( , , , , ). .

, .



(6 2015 , ):

, .

, . addHandlerAsync , , , , , . , , , - (?). asyncStatus.status, .

(function() {
    'use strict';

    // The initialize function must be run each time a new page is loaded
    Office.initialize = function(reason) {
        $(document).ready(function() {
            app.initialize();
            addDocumentHandler();
        });
    };

    function addDocumentHandler() {
        Office.context.document.addHandlerAsync(
            Office.EventType.DocumentSelectionChanged,
            eventHandler,
            function(asyncResult) {
                if (asyncResult.status == "succeeded") {
                    app.showNotification("Success", "Error handler was added");
                } else {
                    app.showNotification("Error setting event: ", JSON.stringify(asyncResult));
                }
            }
        );

        function eventHandler(eventArgs) {
            Office.context.document.getSelectedDataAsync(Office.CoercionType.Text, function(asyncResult) {
                if (asyncResult.status == "succeeded") {
                    app.showNotification("Value of selection: ", asyncResult.value);
                } else {
                    app.showNotification("Error", "Cannot read selection value");
                }
            });
        }
    }
})();

Office API Tutorial App, "SelectionChanged". . ?

enter image description here

~ , Office Extensibility, MSFT

+1

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


All Articles