1

Is it possible to disable a user from being able to add a new sheet to a google spreadsheet? I basically want to disable the "+" and "add 1000 rows" function for a spreadsheet.

Sean

1
  • You could make a set of rules with (onChange)[developers.google.com/apps-script/reference/script/… to delete the newly generated Rows/Columns/Sheets, dunno how well that would respond tough. Could also make a Trigger to check every minute if there's a change and revert it.
    – Kriggs
    Jul 2, 2015 at 14:37

1 Answer 1

1

Generally speaking, you can not change the spreadsheet "native" features, so the answer is no.

You might try a few workarounds as suggested in @Kriggs comment but you probably won't find it very practical.

I suppose you were asking this because some users are messing up your spreadsheets doing unintentional mistakes ? if that's the case then the best approach is probably to create an onOpen function that will "clean up" the document when one opens it, deleting all unnecessary rows and columns and removing empty sheets.

If you need more about how to achieve this please edit your question to add more details.


EDIT :

bonus : demo code

function resetPageLayout() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sh = ss.getSheetByName('Sheet1');
  ss.toast('Now processing your sheet','Wait a few seconds',5);
  if(sh.getMaxRows()-sh.getLastRow()>0){sh.deleteRows(sh.getLastRow()+1, sh.getMaxRows()-sh.getLastRow())};
  if(sh.getMaxColumns()-sh.getLastColumn()>0){sh.deleteColumns(sh.getLastColumn()+1, sh.getMaxColumns()-sh.getLastColumn())};
  var sheets = ss.getSheets();
  for(var n=0;n<sheets.length;n++){
    if(sheets[n].getName()!='Sheet1'){
      try{
        ss.deleteSheet(sheets[n])}catch(err){
          Browser.msgBox('Can\'t delete Sheet named "'+sheets[n].getName()+'" ('+err+')');
        }
    }
  }
     SpreadsheetApp.flush();
}
1
  • Thanks guys. That's exactly the problem is the users are "playing around" with the sheets and attaching forms, adding new sheets, etc. not really breaking anything but more of an annoyance factor. I think I'll try the onOpen trigger to go through and clean up as you've suggested.
    – Sean
    Jul 2, 2015 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.