How do I deselect an active cell when clicking on an image to run a script?

前端 未结 3 1872
再見小時候
再見小時候 2021-01-29 04:28

I have a spreadsheet-bound script that is invoked by clicking an image in the spreadsheet. I\'ve found that the script can be blocked if a cell that it needs to modify is active

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-29 05:11

    Another "solution" to this is not to use a button, but use a check mark as if it we a button, and use the onEdit function.

    function onEdit(e)
    {
     
      var ss = SpreadsheetApp.getActiveSpreadsheet();
    
      checkbox1 = ss.getRange("saveCheckbox_001");
      if (checkbox1.isChecked())
      {
        submit1(); //do all the fun stuff associated with this checkbox
        checkbox1.uncheck();
      }
    
      //more checkbox handling and calling other functions can go here if you need more than one "button"
    
    }
    

提交回复
热议问题