+ Reply to Thread
Results 1 to 5 of 5

User to Enter password to be able to unlock pages

  1. #1
    Registered User
    Join Date
    09-15-2020
    Location
    Melbourne
    MS-Off Ver
    MAc
    Posts
    6

    User to Enter password to be able to unlock pages

    Hello,

    I am working on a document for work which needs to have some tabs hidden and protect. All well and good, however where I have stumbled is for entering in a password only once for the multiple pages.

    I don't want everyone to have access to this, so I want the admin to enter in the correct password. I had found a code but even if I put in the correct password it doesn't work.

    I a fairly new to vba so any help would be greatly appreciated. Current code below:


    Please Login or Register  to view this content.
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #2 requires code tags. I have added them for you this time because you only have a couple of posts. --6StringJazzer
    Last edited by 6StringJazzer; 10-04-2021 at 09:41 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: User to Enter password to be able to unlock pages

    Please show us the code for UnProtectSheets. If you are entering the correct password, the problem could be there.

    Also be aware that this method will work only for compliant users. A malicious user can easily defeat a VBA password scheme. Also, the user has to allow macros to run for it to work at all.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    09-15-2020
    Location
    Melbourne
    MS-Off Ver
    MAc
    Posts
    6

    Re: User to Enter password to be able to unlock pages

    Thanks for the quick reply:

    Sub UnProtectSheets()
    Dim ws As Worksheet
    Dim wsArray
    Set wsArray = Sheets(Array("sheet 1", "sheet 2", "sheet 3"))
    For Each ws In wsArray
    If ws.ProtectContents = True Then
    ws.Unprotect "test"
    End If
    Next ws
    End Sub

  4. #4
    Registered User
    Join Date
    09-15-2020
    Location
    Melbourne
    MS-Off Ver
    MAc
    Posts
    6

    Re: User to Enter password to be able to unlock pages

    Got it working, thanks for your help.

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: User to Enter password to be able to unlock pages

    I fixed your code tags with a notice in the first post, but now I will have to ask you to update post #3.

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)

+ 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. Replies: 11
    Last Post: 10-01-2017, 09:46 AM
  2. Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  3. Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  4. Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  5. Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  6. Replies: 0
    Last Post: 09-05-2005, 10:05 PM
  7. Replies: 1
    Last Post: 06-24-2005, 09:59 AM

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