+ Reply to Thread
Results 1 to 3 of 3

Google Sheets: Lock and Unlock sheets

  1. #1
    Registered User
    Join Date
    04-13-2020
    Location
    Philippines
    MS-Off Ver
    2013
    Posts
    29

    Google Sheets: Lock and Unlock sheets

    So I'm currently working on Protected sheets & ranges. Scripts are included with this. The thing is I have these two buttons which are the Lock and Unlock.

    Everything works fine on the owner's side. So, if we will view this as the user or client-side:

    The Lock button functions as it removes the protected range setting that is created by the owner then creates a new setting that disables all the range from editing. The lock button is accessible by the owner and editors.

    The Unlock button functions as it removes the settings that the lock button has been created and then create settings that have the "except certain cells" for the ranges that need to be editable. So, for the user side, I'm thinking that this button will only be accessible by the owner. The owner is the only one who can use the unlock button for security.

    So the thing is when clicking the lock button on the user side, it gives me an error that says...

    > Exception: You are trying to edit a protected cell or object. Please contact the spreadsheet owner to remove protection if you need to edit.

    But I think I figured out the problem. The error shows when the user is not the one who created the said setting. In short, when the owner is the one who creates the protected settings, the user can't edit it.

    So, I'm trying to figure out how can the editors use the two buttons without receiving that error. I'm new to this area so I don't have an idea on how to exactly execute this thing. As the owner, I need to create the settings before the user can open the file and be the one who can only unlock the sheet for security purposes.

    Here's the visual of the thing that I'm working on...

    Capture.JPG

    Here's the code that I'm currently using

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,147

    Re: Google Sheets: Lock and Unlock sheets

    It seems that, you need to add users by "name" or "e-mail address" using the PROTECTION class.

  3. #3
    Registered User
    Join Date
    04-13-2020
    Location
    Philippines
    MS-Off Ver
    2013
    Posts
    29

    Re: Google Sheets: Lock and Unlock sheets

    Quote Originally Posted by Haluk View Post
    It seems that, you need to add users by "name" or "e-mail address" using the PROTECTION class.
    The unlock button seems to be working fine. I'm having a problem in terms of the lock button.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Google Apps Script for Google Sheets Pulling Formulas from Master to Several Slave Sheets
    By excelroofing in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 4
    Last Post: 08-22-2018, 02:06 AM
  2. [SOLVED] Unlock & Lock Sheets Macro
    By eduardbirkaya in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-24-2017, 12:17 PM
  3. [SOLVED] unlock sheets apply macro then lock sheets again
    By k1dr0ck in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-22-2015, 10:21 PM
  4. Lock and unlock sheets with password , diffrent usernames different actions
    By Barry Engelbrecht in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-20-2013, 07:06 AM
  5. Lock and Unlock sheets in a shared workbook?
    By Dulanic in forum Excel General
    Replies: 0
    Last Post: 02-15-2011, 01:24 PM
  6. Lock and Unlock Sheets based on Cell values
    By Mujahid_Sgd in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-02-2011, 05:18 AM
  7. using VB code to unlock and lock different areas on multiple sheets
    By Healthwatch in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-04-2010, 11:12 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1