Hi there,
Can anyone spot why this code doesn't work. It runs, but will not accept the password I set, which for testing was a simple lower case "hello" placed in A1 on sheet 4.
Kind regards![]()
Please Login or Register to view this content.
Rob
Hi there,
Can anyone spot why this code doesn't work. It runs, but will not accept the password I set, which for testing was a simple lower case "hello" placed in A1 on sheet 4.
Kind regards![]()
Please Login or Register to view this content.
Rob
![]()
Please Login or Register to view this content.
Hmm, no that doesn't work either, I wonder what I am doing wrong.
To clear something up, to unlock the sheet, I am going -Review Tab - Unprotect Sheet and then entering the same password that is being pointed at. This code works so long as I type in the password into the script, but not if I try to reference it on a cell somewhere. i can't get this to work even if the password is on a cell on the same sheet that is right in front of me.
What am I doing wrong here please?
Sorry I was wrong, it doesn't work at all, not even with a password. I beleive the syntax is right, but I guess I am not putting it in the right place. but right now my only way of editing this sheet now is deleting it and starting again, that is not really what I want it to do.
I can only guess the cell you are referring to in the code is not the one you think it is.
Everyone who confuses correlation and causation ends up dead.
Use below code to unlock the sheet.
And try this code to lock, just to make sure you are referring to correct cell.![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
Ah, ok, so I need to unlock it with a script, I can't use the ribbon?
No, the ribbon should work too.
You can unlock using ribbon provided you know the password used to protect. Since I am doubting you are not referring to a cell you think you are, above code would exactly get the password used to lock.
Thank you haripopuri, this does work, yet not with the ribbon, it will only unlock via script. Could that be a bug in the program, or do you have to specify that you want to be able to use the ribbon?
Can you post a workbook showing this? If it is a bug, I'd like to get it filed as that's pretty serious. (Note: I find it hard to believe it would not have been found before this though)
Unfortunately no, I can't upload the workbook as I am at work, all I did was open a new workbook, add an extra worksheet so there was a worksheet 4 in there, then I used this script and run them as needed to get an idea of what was working or not. I am running windows 7 using microsoft office 2007 enterprise.
Kind regards![]()
Please Login or Register to view this content.
Rob
Ok lets do this. Run below macro once and notice the message box that appear after you run this macro What does it say...
and what happen when you use the same password shown in the box from ribbon to unlock?![]()
Please Login or Register to view this content.
I don't have 2007 here but it's fine in 2010. I will double-check 2007 later but I would be very surprised if it fails there. It would have to have been spotted by now if it's a bug in 2007.
One thing to note: if you had already protected Sheet1 with a different password than the one in Sheet4 cell A1, that password would still be in effect, not the one the code tried to apply, but that would impact both methods of unprotecting the sheet.
One other check - you don't have Caps Lock on by any chance?![]()
No, I did check for that I even typed the password (which in this case was "One") into another cell then copied and pasted it, though that didn't work, as I was unable to paste into the password box, but it would have flagged up a caps lock issue if that had been the case.
Hello Rob K,
I have done exactly what you did, and even went one step furher by saving it as a Excel 2003 .xls version.
I am runing Excel 2007, and it works fine without any issues.
Please try the attached sample Workbook.
Regards.
Please consider:
Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .
Hi, hopefully, I have successfully attached this for you.
Regards
Rob
What password are you trying? You know there's a space on the end of "One " in A1 on Sheet4?
Hello Rob K,
Please try your attached, revised Workbook now.
Regards.
Wow, that is very astute to spot that one, thank you so much, yes it all works well now, it must be my dyslexic thumb being a little over keen on the space bar.
Phew. It got me worried for a while.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks