+ Reply to Thread
Results 1 to 14 of 14

Establish the Unprotect Password

  1. #1
    Registered User
    Join Date
    07-26-2010
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    14

    Exclamation Establish the Unprotect Password

    Hello,

    I recently sent out about 200 workbooks, half with one protect password and the rest with another (for this purpose we will make the passwords passA and passB). What I am trying to do via Excel macro is establish what password that sheet is using.

    Now I have tried
    Please Login or Register  to view this content.
    Now of course this doesn't work... any advise?

    Regards,
    Last edited by jrheeder; 07-27-2010 at 06:47 AM. Reason: tmake it more readable

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

    Re: Establish the Unprotect Password

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    I have added them this time, maybe
    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
    07-26-2010
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    14

    Exclamation Re: Establish the Unprotect Password

    Quote Originally Posted by royUK View Post
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    I have added them this time, maybe
    Please Login or Register  to view this content.
    Roy,

    Apologies for the mistake I will endeavour to avoid making that mistake again. Now onto the code, I have done that, one small issue appears. It might be more clear if I tell you what I am look to achieve. I will be running through the column A and find if the cell is empty. if it is, then I need then to unlock(unprotect) the worksheet to the highlight the cell in question and then lock(protect) the sheet using the same password.

    No that you have a better idea what I am trying to achieve, this is my current code:

    Please Login or Register  to view this content.
    Now I know this code very untidy and I am re-looking at it, but any advise?

    Regards,

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

    Re: Establish the Unprotect Password

    What's not working?

  5. #5
    Registered User
    Join Date
    07-26-2010
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Establish the Unprotect Password

    No for some unknown reason.

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

    Re: Establish the Unprotect Password

    I can't test the code so what error messages are being seen, what is actually happening?

  7. #7
    Registered User
    Join Date
    07-26-2010
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Establish the Unprotect Password

    As far as I can establish it cycles through the code fine the first time but after that it doesn't go past
    Please Login or Register  to view this content.
    and throws back

    Run-time error '1004'

    The password you supplied is not correct. Verify that the CAPS LOCK key is off and be sure to use the correct capitalisation.

  8. #8
    Registered User
    Join Date
    07-26-2010
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Establish the Unprotect Password

    Also tried to make "passB" the first option but the same outcome came out. It deffo stops after the first option.

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

    Re: Establish the Unprotect Password

    Are you using the correct passwords?

  10. #10
    Registered User
    Join Date
    07-26-2010
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Establish the Unprotect Password

    Quote Originally Posted by royUK View Post
    Are you using the correct passwords?
    Yep, there is only two passwords passA and passB

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

    Re: Establish the Unprotect Password

    If the actual passwords are as you say then you need to add speech marks in the code
    "PassA" & "PassB"

  12. #12
    Registered User
    Join Date
    07-26-2010
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Establish the Unprotect Password

    Quote Originally Posted by jrheeder View Post
    Roy,

    Apologies for the mistake I will endeavour to avoid making that mistake again. Now onto the code, I have done that, one small issue appears. It might be more clear if I tell you what I am look to achieve. I will be running through the column A and find if the cell is empty. if it is, then I need then to unlock(unprotect) the worksheet to the highlight the cell in question and then lock(protect) the sheet using the same password.

    No that you have a better idea what I am trying to achieve, this is my current code:

    Please Login or Register  to view this content.
    Now I know this code very untidy and I am re-looking at it, but any advise?

    Regards,
    As you can see here I did add speech-marks. Hmm this is an interesting pickle

  13. #13
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,978

    Re: Establish the Unprotect Password

    You don't have a resume statement, therefore everything after your first on error goto line is actually an error handler (i.e. the whole of the rest of your loop) and an error that occurs in an error handler will cause a run-time error. I would suggest you move the password but to a separate function - something like:
    Please Login or Register  to view this content.
    and then call that from your code like so:
    Please Login or Register  to view this content.
    Everyone who confuses correlation and causation ends up dead.

  14. #14
    Registered User
    Join Date
    07-26-2010
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Establish the Unprotect Password

    Quote Originally Posted by romperstomper View Post
    You don't have a resume statement, therefore everything after your first on error goto line is actually an error handler (i.e. the whole of the rest of your loop) and an error that occurs in an error handler will cause a run-time error.
    This did the trick, never realised I didn't have a resume procedure in place. Learned something new. Thank you
    Last edited by romperstomper; 07-27-2010 at 06:59 AM. Reason: No need to quote the whole post!

+ 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