Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to retrive password protected worksheet but forgot password? Laurie Excel Worksheet Functions 1 November 19th 09 09:42 PM
password to open Excel file option does not exist SabrinaN Excel Worksheet Functions 4 January 23rd 06 02:55 AM
how to automate opening a password protected excel file? e.g. a .xls that has a password set in the security tab. Daniel Excel Worksheet Functions 0 June 23rd 05 11:56 PM
bypass password when update linking of password protected file Yan Excel Discussion (Misc queries) 1 February 7th 05 11:29 PM
Excel password but cant hide the sheets before entering password cakonopka[_3_] Excel Programming 1 January 30th 04 06:28 PM


All times are GMT +1. The time now is 06:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"