Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

104
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda