2

What I want to do is

Make a copy of the sheet and remove all protected ranges from copied sheet.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var timezone = "GMT-5"
var timeformat = "yyyy-MM-dd"
var date = Utilities.formatDate(new Date(), timezone, timeformat);

var file = DriveApp.getFileById(SpreadsheetApp.getActiveSpreadsheet().getId()).makeCopy(date + " " + ss.getName());

var editors = DriveApp.getFileById(SpreadsheetApp.getActiveSpreadsheet().getId()).getEditors();
  for (var i = 0; i < editors.length;i++) {    
      file.addEditor(editors[i])    
  }

  var viewers = DriveApp.getFileById(SpreadsheetApp.getActiveSpreadsheet().getId()).getViewers();

  for (var i = 0; i < viewers.length;i++) {    
      file.addViewer(viewers[i])

this is what I'm doing to make a copy of the sheet.

1

Looks like all you already have the copying part done, with file being the handle of the copy. All that remains to do is to open the file with SpreadsheetApp and then use the methods of Protection class:

var ss = SpreadsheetApp.open(file); 
var protections = ss.getProtections(SpreadsheetApp.ProtectionType.RANGE);
for (var i = 0; i < protections.length; i++) {
  protections[i].remove();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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