+ Reply to Thread
Results 1 to 5 of 5

Does a password exist...?

  1. #1
    Registered User
    Join Date
    03-17-2005
    Posts
    34

    Question 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

  2. #2
    NickHK
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    >
    > 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. #3
    Registered User
    Join Date
    03-17-2005
    Posts
    34
    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

  4. #4
    STEVE BELL
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    >
    > 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. #5
    Registered User
    Join Date
    03-17-2005
    Posts
    34
    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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1