0
votes

I work on Excel addin and use office.js library. My addin should save some data on server, entered into cells after user pressed "SaveData" button on task pane. Everything works fine except the situation when user entered something into cell and immediately (without pressing enter or click on another cell) clicked on button "SaveData". I'm getting error with code "InvalidOperationInCellEditMode" and description "Excel is on the cell edit mode...".

I added following code that catches this exception and shows message on the task pane but it could not be supposed as a user friendly behaviour.

function SaveData() {

    Excel.run(function (ctx) { 

        return ctx.sync().then(function() {
        // HERE I HAVE SOME CODE THAT WORKS IF CELL IS NOT BEING EDITED
        });
    }).catch(function(error) {
        console.log("Error: " + error);
        if (error instanceof OfficeExtension.Error) {
            console.log("Debug info: " + JSON.stringify(error.debugInfo));
            // HERE I HAVE SOME CODE THAT SHOWS MESSGE ON TASK PANE

        }
    });
}

Is there any way to block task pane when user is editing cell like it works for some native Excel buttons?

UPDATE1: Is it possible to finish user's edit by API and execute code after that?

2

2 Answers

1
votes

thanks for the feedback.

I'm an engineer working on Office JavaScript APIs. To your question, there is no way to disable task pane yet. But we did another improvement in our beta APIs, which could delay the API execution until user exits the CellEditMode.

If that could help, please let me know and I can share more details.

0
votes

We have another one way to solve this problem.Write text in Body "Please Press the Enter key or ESC in Excel Sheet".