Google spreadsheet - Error when Remove range protection

Sean Sugden

Here's my script, but I can't get it to work for some weird reason??!!! Driving me nuts.

function removeThenSetProtection() {
  // Remove all range protections in the spreadsheet that the user has
  //permission to edit.
  var ss = SpreadsheetApp.getActive();
  var protections = ss.getProtections(SpreadsheetApp.ProtectionType.SHEET);

  for (var i = 0; i < protections.length; i++) {
    var protection = protections[i];
    if (protection.canEdit()) {
      protection.remove();
    }
  }
}
Alan Wells

Change:

var protections = ss.getProtections(SpreadsheetApp.ProtectionType.RANGE);

To:

var protections = ss.getProtections(SpreadsheetApp.ProtectionType.SHEET);

That way, you'll be assured that you are getting a reference to everything that is protected, and future conflicts don't happen.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

"Service Error: Spreadsheets" Error - Google Script Issue with Protection Class

분류에서Dev

Google spreadsheet formula which takes its cell range values from other cell?

분류에서Dev

Google Spreadsheet custom function to add csv in spreadsheet

분류에서Dev

Remove all hyperlinks from a spreadsheet

분류에서Dev

Adding Images Efficiently to a Google Spreadsheet

분류에서Dev

Using SUMIF correctly on google spreadsheet

분류에서Dev

Date stamp for google-spreadsheet

분류에서Dev

modifying another spreadsheet from within a spreadsheet : Google Apps Script

분류에서Dev

Error : Could not find or load main class Protection

분류에서Dev

HTTP Get in Google Spreadsheet, "e undefined"

분류에서Dev

Update/Add data to Google Spreadsheet Database

분류에서Dev

Google Spreadsheet - How to avoid sending email duplicates?

분류에서Dev

Is there a faster way to create google spreadsheet in specific folder?

분류에서Dev

Hide Rows Based on Content of a Cell - Google Spreadsheet

분류에서Dev

Google spreadsheet query execute for entire column

분류에서Dev

Error when trying to install/remove programs after upgrade to Ubuntu 13.10

분류에서Dev

#NAME? error after opening spreadsheet with macro

분류에서Dev

Matlab: Calculating the standard error of values in a spreadsheet

분류에서Dev

Protect Excel Spreadsheet with a macro when a condition is satisfied

분류에서Dev

I want to remove some pics from my Excel spreadsheet

분류에서Dev

Overflow error : range()

분류에서Dev

LINQPad error: Context is inaccessible due to its protection level

분류에서Dev

GroceryCRUD add, edit buttons not working when enabling CodeIgniter CSRF protection

분류에서Dev

CodeIgniter: Website displays database error when accessed through Google

분류에서Dev

php-google-spreadsheet-client getSpreadsheets returning empty array

분류에서Dev

regex to match first n lines after a specific word in Google Spreadsheet

분류에서Dev

What is a good way to call a python script from a Google Sheets spreadsheet?

분류에서Dev

Is It Possible To Write Username Of Editor To Cell In Google Docs Spreadsheet

분류에서Dev

Google Script for spreadsheet to extract data from a PDF page linked on the sheet

Related 관련 기사

  1. 1

    "Service Error: Spreadsheets" Error - Google Script Issue with Protection Class

  2. 2

    Google spreadsheet formula which takes its cell range values from other cell?

  3. 3

    Google Spreadsheet custom function to add csv in spreadsheet

  4. 4

    Remove all hyperlinks from a spreadsheet

  5. 5

    Adding Images Efficiently to a Google Spreadsheet

  6. 6

    Using SUMIF correctly on google spreadsheet

  7. 7

    Date stamp for google-spreadsheet

  8. 8

    modifying another spreadsheet from within a spreadsheet : Google Apps Script

  9. 9

    Error : Could not find or load main class Protection

  10. 10

    HTTP Get in Google Spreadsheet, "e undefined"

  11. 11

    Update/Add data to Google Spreadsheet Database

  12. 12

    Google Spreadsheet - How to avoid sending email duplicates?

  13. 13

    Is there a faster way to create google spreadsheet in specific folder?

  14. 14

    Hide Rows Based on Content of a Cell - Google Spreadsheet

  15. 15

    Google spreadsheet query execute for entire column

  16. 16

    Error when trying to install/remove programs after upgrade to Ubuntu 13.10

  17. 17

    #NAME? error after opening spreadsheet with macro

  18. 18

    Matlab: Calculating the standard error of values in a spreadsheet

  19. 19

    Protect Excel Spreadsheet with a macro when a condition is satisfied

  20. 20

    I want to remove some pics from my Excel spreadsheet

  21. 21

    Overflow error : range()

  22. 22

    LINQPad error: Context is inaccessible due to its protection level

  23. 23

    GroceryCRUD add, edit buttons not working when enabling CodeIgniter CSRF protection

  24. 24

    CodeIgniter: Website displays database error when accessed through Google

  25. 25

    php-google-spreadsheet-client getSpreadsheets returning empty array

  26. 26

    regex to match first n lines after a specific word in Google Spreadsheet

  27. 27

    What is a good way to call a python script from a Google Sheets spreadsheet?

  28. 28

    Is It Possible To Write Username Of Editor To Cell In Google Docs Spreadsheet

  29. 29

    Google Script for spreadsheet to extract data from a PDF page linked on the sheet

뜨겁다태그

보관