+ Reply to Thread
Results 1 to 7 of 7

Protect & unprotect an array of worksheets across multiple workbooks

  1. #1
    Registered User
    Join Date
    12-06-2012
    Location
    Bloomsburg, PA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Protect & unprotect an array of worksheets across multiple workbooks

    I am trying to apply a new password across 50+ workbooks, but only on specific pages. Each worksheet within these 50+ workbooks uses the same password.

    I came up with the following code (which I'm new at), but I am hitting a snag. I get an error "Invalid Use of Property". Can someone help?

    Thank you!

    Please Login or Register  to view this content.
    Moderator's Edit: Use code tags when posting code. To do so in future, select the code and click on the # icon at the top of your post window.
    Last edited by arlu1201; 12-07-2012 at 01:30 AM.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Protect & unprotect an array of worksheets across multiple workbooks

    Hi, carwil,

    AFAIK UserInterfacecOnly is volatile and needs to be set on every opening of the workbook. Code is untested:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    12-06-2012
    Location
    Bloomsburg, PA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Post Re: Protect & unprotect an array of worksheets across multiple workbooks

    Hi Holger,
    Thank you so much for your reply. Your solution works fine on individual workbooks, however I was attempting to change the passwords in all of my workbooks in one folder.

    I have a macro that clears specific cells in all workbooks within a folder and I was hoping to accomplish the same type process with the unprotect/protect passwords.

    Is that possible?
    Thank you!

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Protect & unprotect an array of worksheets across multiple workbooks

    Hi, carwil,

    please give this code a try:
    Please Login or Register  to view this content.
    Ciao,
    Holger

  5. #5
    Registered User
    Join Date
    12-06-2012
    Location
    Bloomsburg, PA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Protect & unprotect an array of worksheets across multiple workbooks

    Holger,
    That works beautifully! I did run into a problem -- one workbook had a different password. That being said, when the macro came to that workbook it stopped running. When I corrected the password and tried to resume the macro I received a run-time error, "The password you supplied is not correct..." because when the macro was started again the first pass of the macro had corrected it. Is there a way to skip over a workbook if the password doesn't match "oldpassword"?
    Thank you!

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Protect & unprotect an array of worksheets across multiple workbooks

    Hi, carwil,

    and how shall we handle this? One option is to use an Inputbox to ask for a password. Here you are asked to insert a password. After that the macro tries to unprotect the sheet with that password. This continues until you give in the correct password (code is continued) or you press Cancel (a different message will be displayed at the end). This code is untested:
    Please Login or Register  to view this content.
    Ciao,
    Holger

  7. #7
    Registered User
    Join Date
    12-06-2012
    Location
    Bloomsburg, PA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Protect & unprotect an array of worksheets across multiple workbooks

    Good morning, Holger.

    Your final option worked perfectly. I could not have done this without you. I appreciate your time and patience working me to find a solution. It saved me an inordinate amount of time with so many workbooks to adjust.

    Than you again, and happy holidays!
    carwil

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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