What has my macro done to my password?

T

Tonso

I created a macro, and used the Activesheet.Unprotect Password:="trip"
to protect it. But, I left out the : after "Password". When i tried to
run the macro i got a debug message. Now, "trip" will not unprotect my
sheet, and i have no idea how to get it unprotected. Can anypone
figure out what the password has been changed to?

Thanks,
Tonso
 
T

Tonso

I created a macro, and used the Activesheet.Unprotect Password:="trip"
to protect it. But, I left out the : after "Password". When i tried to
run the macro i got a debug message. Now, "trip" will not unprotect my
sheet, and i have no idea how to get it unprotected. Can anypone
figure out what the password has been changed to?

Thanks,
Tonso

I should add that i also left out the : after Password when I wrote
the Actvicesheet.Protect=:"trip"
Tonso
 
D

Dave Peterson

I bet you used:

Activesheet.Protect Password = "trip"
(not .unprotect)

You could either use code:
Activesheet.Unprotect Password = "trip"

or manually unprotect it using
FALSE
(all upper case)

Password = "trip"
is essentially a boolean comparison.

And since Password hasn't be declared, excel sees it as empty. So that boolean
comparison evaluates to FALSE.

If you add
Option Explicit
to the top of your module, then your code wouldn't have compiled--you would have
to declare all your variable explicitly. Excel/VBA would have seen Password as
an undeclared variable and you would have been safe(r).
 
T

Tonso

I bet you used:

Activesheet.Protect Password = "trip"
(not .unprotect)

You could either use code:
Activesheet.Unprotect Password = "trip"

or manually unprotect it using
FALSE
(all upper case)

Password = "trip"
is essentially a boolean comparison.

And since Password hasn't be declared, excel sees it as empty.  So that boolean
comparison evaluates to FALSE.

If you add
Option Explicit
to the top of your module, then your code wouldn't have compiled--you would have
to declare all your variable explicitly.  Excel/VBA would have seen Password as
an undeclared variable and you would have been safe(r).

Dave,
You are right! Thanks immensely!
Tonso
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top