I have a Google sheets spreadsheet with few sheets named: "Form Responses 1", "Form Responses 2", "Form Responses 3" and "Sheet1". I wrote a code that delete all sheets except "Sheet1":
When I make run the function it gives me an error:
You cannot delete a sheet with a linked form. Please unlink the form first.
How can I unlink the Form from the sheet? See the code of the function below.
function clearForms()
{
var ss = SpreadsheetApp.getActiveSpreadsheet();
var numsheets = ss.getNumSheets()-1;
var sheets = ss.getSheets();
var i=numsheets;
while (i >=0)
{
if ( sheets[i].getName() != "Sheet1") {
Logger.log(sheets[i].getName()+" Deleted");
ss.deleteSheet(sheets[i]);
}
i--;
}
}
Thanks.