+ Reply to Thread
Results 1 to 14 of 14

Creating buttons to protect/unprotect worksheet

  1. #1
    Registered User
    Join Date
    01-14-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    72

    Creating buttons to protect/unprotect worksheet

    Just wondering if someone would be able to help me with the code required to create a button for protecting the worksheet and a button for unprotecting the worksheet
    Last edited by torontoguy; 01-22-2009 at 09:39 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Add a button from the Control ToolBox then use this code

    Please Login or Register  to view this content.
    Hope that helps.

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

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    01-14-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    72
    there seemed to be a problem with that code

    "compile error"
    invalid use of me keyword

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Have you used a button from the Controls ToolBox & where have you placed the code?
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    01-14-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    72
    noob question: where do i find the create command button in xl 2007?

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    If I remember correctly it is in the Developer Tab -> Insert

  7. #7
    Registered User
    Join Date
    01-14-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    72
    perfect

    thank you!

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Glad it helped

  9. #9
    Registered User
    Join Date
    01-14-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    72
    ah darn, I have a problem... the password doesnt seem to be working. I tried with the change: 1234 instead of secret but it doesnt seem to ask for it when clicking "unprotect worksheet"

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    That's because the password is hard coded, do you want to ask for the password? This will add the password automatically & prompt for unprotecting

    O
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    01-14-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    72
    awesome. thanks again!
    Last edited by torontoguy; 01-22-2009 at 09:50 AM.

  12. #12
    Registered User
    Join Date
    01-14-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    72
    If you could please delete the message above

    AND here's my problem:

    -when a user enters the wrong password, it takes them to the debugger
    which contains the code for the button.. and unfortunately, the password
    as well

  13. #13
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You can stop the debugger by protecting the vba project which is a must where passwords are involved.

    Add error handler to alert about wrong password
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    01-14-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    72
    Awesome. It works great! (I guess you expected that)

+ 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