Hello everyone.
I am in need of a code that can track which cells are active or selected, and then block them once a user is no longer interacting with them. I understand that there may be some issues, especially if the user selects a cell but does not make any changes. Unfortunately, we do not currently have support for an 'onChange' event handler to address this issue. The main problem I am facing is when the user starts editing a cell, the getActiveCell/getSelectedRange method fails and causes the script to stop running, even though it is enclosed within a try block. The code snippet below illustrates the core concept, where it identifies which cell the user is in and detects when they leave that cell. My next step would be to replace the console.log function with setLock to enhance functionality.
function main(workbook: ExcelScript.Workbook)
{
while(true){
try{
let cell = workbook.getSelectedRange().getAddress();
}
catch(e){}
console.log(cell)
while(workbook.getSelectedRange().getAddress() == cell){}
}
}