+ Reply to Thread
Results 1 to 11 of 11

No password asked when using VBA to protect Sheet

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-30-2007
    Location
    London, UK
    MS-Off Ver
    Microsoft Office 2007
    Posts
    317

    Lightbulb No password asked when using VBA to protect Sheet

    Hi Guys,

    This question is related to my post here:
    http://www.excelforum.com/showthread.php?t=634024

    When you protect a worksheet via VBA then unprotect it the conventional way via: Tools>Protection>Unprotect Sheet. Why is it when you unprotect a worksheet in this way Excel does not ask you for a Password. You simpy only have to select Unprotect Sheet and the sheet is unprotected which for me kinda defeats the object.

    What am I doing wrong?

    Thanks in advance for any help given.
    Best Regards.

    Michael
    -----------------------------------
    Windows Vista, Microsoft Office 2007

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Excel VBA will not unprotect a password protected sheet without the prompt for a password, whether set by VBA or manually.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    03-30-2007
    Location
    London, UK
    MS-Off Ver
    Microsoft Office 2007
    Posts
    317

    Smile

    Quote Originally Posted by royUK
    Excel VBA will not unprotect a password protected sheet without the prompt for a password, whether set by VBA or manually.
    Thanks for your reply but I am still confused.

    I originally set my password Manually, now if I unprotect Manually Excel will prompt me for a password.

    Then I had my vba code to unlock a range of cells and in order to do this I used the Unprotect function in VBA then changed the cell status to unlock and then the code re-Protected the sheet with my chosen password.

    Now if I manually unprotect the worksheet Excel no longer prompts me for the password and simply unprotects the sheet as if I just protected the sheet without setting a password. How can I change this so that Excel still prompts me for a password when I use VBA code to protect the sheet?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Quote Originally Posted by Zyphon
    Thanks for your reply but I am still confused.

    I originally set my password Manually, now if I unprotect Manually Excel will prompt me for a password.

    Then I had my vba code to unlock a range of cells and in order to do this I used the Unprotect function in VBA then changed the cell status to unlock and then the code re-Protected the sheet with my chosen password.

    Now if I manually unprotect the worksheet Excel no longer prompts me for the password and simply unprotects the sheet as if I just protected the sheet without setting a password. How can I change this so that Excel still prompts me for a password when I use VBA code to protect the sheet?
    AFAIK a password set in VBA will still prompt for a password when manually unprotecting the sheet.

  5. #5
    Forum Contributor
    Join Date
    03-30-2007
    Location
    London, UK
    MS-Off Ver
    Microsoft Office 2007
    Posts
    317

    Exclamation

    Quote Originally Posted by royUK
    AFAIK a password set in VBA will still prompt for a password when manually unprotecting the sheet.
    Hi royUK,

    For some strange reason it is not prompting me when I manually unprotect the sheet. I thought the same as you that when you protect a sheet in VBA Excel should still prompt you for a password when unprotecting a sheet manually.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I've never come across this, maybe you can attach your workbook.

+ 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