Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

102
Views
Disable Spreadsheet Copy

Can someone help me fix the following code?

I using this script to disable editor to copy my Google spreadsheet

function onOpen ()  {   
  const ss = SpreadsheetApp.getActive();   
  const id = ss.getId();   
 if (id !== '1ld8aPE5zVBYoT39WPzZjWxU1uHJ8lVVV5vkBiv5USzI') ss.getSheets().forEach((s) => ss.deleteSheet(s)); }

Reference.

Disable Spreadsheet copy - Google Sheets

I tried copying to another worksheet but code wont work

Example https://drive.google.com/drive/folders/11Jqh_xaw0CdI1cBUL_hZwCjOJNnRKSU6?usp=sharing

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Tl;Dr There is no way to prevent that spreadsheet editors copy the spreadsheet, because of this, in order to prevent that editors copy the spreadsheet you should use another approach to whatever you are doing with your spreadsheet.

Regarding the code in the question, it doesn't disable spreadsheet copy, what it does is, if the spreadsheet id is not equal to certain value, iterates over all the sheets but as it's not possible to delete all the sheets as each spreadsheet should include at least one sheet, the script throws an error. You might change the script i.e. inserting a new sheet and delete the other sheets, but the editor of the original spreadsheet, as there are the owner of the copy, they will be able to delete the script and restore the deleted data from the version history of the new spreadsheet.

Related

  • Disable Spreadsheet copy - Google Sheets
about 4 years ago · Juan Pablo Isaza Report

0

At least, you can add a sheet with an alert and delete all other sheets

var id = '1ld8aPE5zVBYoT39WPzZjWxU1uHJ8lVVV5vkBiv5USzI'
function onOpen() {
  var ss = SpreadsheetApp.getActiveSpreadsheet()
  if (ss.getId() != id) {
    var gid = ss.insertSheet().getSheetId()
    ss.getSheets().forEach(function (sh) {
      if (sh.getSheetId() != gid) { ss.deleteSheet(sh) }
    })
  }
}

I am not sure that there is no bypass! See Rubén's advice.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!