Add Workbook.CancelEdit or WorkSheet.CancelEdit to get around GeneralExceptionError when cell being edited
It would be great to have a CancelEdit or have the Range Select / setting range values automatically cancel the editing and avoid this error which seems to have no workaround.
Whenever a cell is being edited by the user, any attempt to select a different range or update values in different ranges causes the General Exception error. There is no method to Cancel the Edit (essentially just need to send the ESCAPE keystroke to the workbook).
To reproduced just double-click on a cell to go into edit mode and then execution of this code fails:
Excel.run(function (ctx) {
//this line enough to fail
return ctx.sync();
}).catch(function (error) {
})
See this thread:
https://stackoverflow.com/questions/38307300/generalexception-if-cell-being-edited

Hi Brian. Thank you for your input, it is greatly appreciated! We’ve added this to our backlog as something we want to implement. There are many items on the backlog, so we can’t set an exact estimated time for this, but we’ll keep you posted with status updates.
Thanks!
Office Extensibility Team
2 comments
-
atti commented
Note that there is this requirement that could also help in certain cases:
https://officespdev.uservoice.com/forums/224641-feature-requests-and-feedback/suggestions/31752895-js-api-function-to-prevent-user-from-sheet-interac -
atti commented
This is extremely annoying thing! Note that it completely breaks functionality of many addins!
We definitely need to have some option how to cancel the edit OR JS API should work fine even when in this mode (at least reading operations like getting cell address should work!).