ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Does a password exist...? (https://www.excelbanter.com/excel-programming/330450-does-password-exist.html)

DJB[_2_]

Does a password exist...?
 

Hi everyone

I am using these two lines of code to determine whether or not workbook
protection or worksheet protection has been turned on.

If ActiveWorkbook.ProtectStructure = True Then ...
If ActiveSheet.ProtectContents = True Then ...

this works fine,but I would like to know of it is possible to detect if
either of these methods of protection, if being used, are password
protected. I am a bit stumped here.

Thanks for any advice.

DJB


--
DJB
------------------------------------------------------------------------
DJB's Profile: http://www.excelforum.com/member.php...o&userid=21221
View this thread: http://www.excelforum.com/showthread...hreadid=375003


NickHK

Does a password exist...?
 
DJB,
You could try to unprotect the object without supplying a password.
If it fails, then a password is required.

NickHK

"DJB" wrote in message
...

Hi everyone

I am using these two lines of code to determine whether or not workbook
protection or worksheet protection has been turned on.

If ActiveWorkbook.ProtectStructure = True Then ...
If ActiveSheet.ProtectContents = True Then ...

this works fine,but I would like to know of it is possible to detect if
either of these methods of protection, if being used, are password
protected. I am a bit stumped here.

Thanks for any advice.

DJB


--
DJB
------------------------------------------------------------------------
DJB's Profile:

http://www.excelforum.com/member.php...o&userid=21221
View this thread: http://www.excelforum.com/showthread...hreadid=375003




DJB[_3_]

Does a password exist...?
 

Hi Nick and thanks for your suggestion.

However, if you try to unprotect a password protected worksheet or
workbook using a macro, it doesn't fail, it just asks you for the
password.

Any other ideas? Anyone...?

Thanks

DJB


--
DJB
------------------------------------------------------------------------
DJB's Profile: http://www.excelforum.com/member.php...o&userid=21221
View this thread: http://www.excelforum.com/showthread...hreadid=375003


STEVE BELL

Does a password exist...?
 
Try:

Application.DisplayAlerts = False

On Error GoTo line1:
ActiveSheet.Unprotect password:=""
Application.DisplayAlerts = True
Exit Sub
line1:
MsgBox "Password reguired"
Application.DisplayAlerts = True
--
rand451
"DJB" wrote in message
...

Hi Nick and thanks for your suggestion.

However, if you try to unprotect a password protected worksheet or
workbook using a macro, it doesn't fail, it just asks you for the
password.

Any other ideas? Anyone...?

Thanks

DJB


--
DJB
------------------------------------------------------------------------
DJB's Profile:
http://www.excelforum.com/member.php...o&userid=21221
View this thread: http://www.excelforum.com/showthread...hreadid=375003




DJB[_4_]

Does a password exist...?
 

Thanks very much for your help guys.

I was hoping that there would be a read only flag I could check or
something like that - I really only wanted to return the information,
not turn the protection off - but it seems it doesn't work that way!

Anyway, thanks for the example code - it's got me sorted on the right
track.

Thanks again!

DJB


--
DJB
------------------------------------------------------------------------
DJB's Profile: http://www.excelforum.com/member.php...o&userid=21221
View this thread: http://www.excelforum.com/showthread...hreadid=375003



All times are GMT +1. The time now is 01:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com