Password question, but not a "how to crack" question.

jproffer

Well-known Member
Joined
Dec 15, 2004
Messages
2,647
Hi folks,

I wonder if anyone knows a way to determine if a worksheet is protected WITH a password vs. protected without a password. I know how to check for protection in general...but not how to figure out if there's a password attached to that protection.

Any insight/direction is greatly appreciated :)
 
Re: Password questiion, but not a "how to crack" question.

That's what I was thinking. That's going to be (part of) tomorrow's work. One question that will help though. The line "On Error Goto 0".....what is zero? Is it the end of the routine (similar to "Exit Sub") or is it the beginning of the routine or.......what?
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Re: Password questiion, but not a "how to crack" question.

No, zero is just the default, which is to pop-up errors as they occur.
So, it really is just shutting custom error-handling off at that point.
 
Upvote 0
Re: Password questiion, but not a "how to crack" question.

I see, I see....ok that might help tomorrow. Thank you for that.

I'm sure there are better ways than what I'll come up with, but I'd still like to try before coming and asking. :)

We'll see how it goes
 
Upvote 0
Re: Password questiion, but not a "how to crack" question.

Ok, this is what I came up with. Anyone see anything wrong with it? Or see a better way to do it?

Code:
If ws.ProtectContents = True Then WsProConState = True
        If ws.ProtectDrawingObjects = True Then WsProDrawState = True
        If ws.ProtectScenarios = True Then WsProScenState = True
            
            On Error Resume Next
                ws.Unprotect ""
            On Error GoTo 0
                If ws.ProtectContents Or ws.ProtectDrawingObjects Or ws.ProtectScenarios Then
                    HasPW = "Has Password"
                Else
                    HasPW = "No Password"
                End If
                
        If WsProConState = True Or WsProDrawState = True Or WsProScenState = True Then ws.Protect
 
Upvote 0
Re: Password questiion, but not a "how to crack" question.

Ok, one more question. Not exactly related to this, but kind of....

Is there a way to stop the password popup from showing? Like I said, the loading of the listbox is working great now, but I have a button to allow the user to unprotect sheets IF there is no password. If I click a sheet that has a password (which does show up in the listbox now as well) and then click the unprotect button, it shows the password dialog. I'm hoping to just have it do nothing, and not unprotect that particular sheet (because, needless to say, it can't without a password).

I've tried "EnableEvents = False" and "DisplayAlerts = False" with no luck. Is there something else I can "turn off" temporarily to kill that popup?
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,021
Latest member
pingpong7117

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top