Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking the Value of a Password 1

Status
Not open for further replies.

rschneeg

IS-IT--Management
Joined
Nov 3, 2004
Messages
15
Location
US
I've protected an excel sheet with a password. I know the old value and have successfully unprotected it to run some macro on the form.

I now want to be able to change the password in vb from the old value to the new.

How do I check the value of the current password to see if it's the old one or the new one?

I know how to protect and unprotect using the ActiveSheet. Protect.Password but do not know how to do an IF statement to see which one it is.

thanks
 
Hi,

You can't. Otherwise it would be a trivial matter to crack a password.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
If you know the password is one of two, it should be trivial to try them both to see which one works.

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
Except you can not trap any error in the traditional sense. If you "try" one, and it is wrong, there is a run-time stoppage.

faq219-2884

Gerry
My paintings and sculpture
 
Gerry, with sheet protection in Excel 2003 - this works for me
Code:
Sub Macro2()
On Error Resume Next
    ActiveSheet.Unprotect Password:="test2"
    ActiveSheet.Unprotect Password:="test"
End Sub

Gavin
 
Thanks to all who replied.
The ON ERROR works perfectly.
Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top