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?