Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Mar 2003
    Location
    Elkins Park, Pennsylvania, USA
    Posts
    325
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can I check for document protection? (Word XP)

    Hi all. We have an automated system that manipulates Word and Word documents via VB. One of the problems that has come up is that some Word files are being supplied to this process by authors who have password-protected their documents. Since this VB app is designed to run unattended, the unexpected dialog box that pops up in these instances (and waits for user intervention) halts the system.
    My only thought is to create a function that can be called before the document is opened, which will determine if there is any such protection and throw an alert if there is.
    So, does anyone know if this is even possible?
    <font face="Comic Sans MS">That's what you do in a herd; you look out for each other!</font face=comic> - Mike

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Can I check for document protection? (Word XP)

    If

    ActiveDocument.ProtectionType = wdNoProtection

    returns True then the document is not protected.
    -John ... I float in liquid gardens
    UTC -7ąDS

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Can I check for document protection? (Word XP)

    By protection, if you mean a password to open, I think this has come up in past threads regarding automated/batch processing. Hopefully a bit of searching will yield a solution. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Can I check for document protection? (Word XP)

    As far as I know, you can't tell whether a document is password-protected without opening it. You can do the following:
    - Open the documents with an arbitrary password, e.g. "A".
    - If the document is not password-protected (or if it happens to be protected with password "A" <img src=/S/grin.gif border=0 alt=grin width=15 height=15>), it'll be opened without problem.
    - If the document is password-protected, error 5408 (Password not correct) will occur, you can trap this with an error handler and either put up an alert or skip the document and continue with the next.

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can I check for document protection? (Word XP)

    > So, does anyone know if this is even possible?

    If you are processing documents in unattended mode, there is always the possibility of un-trappable errors because MSoft Word employs 3rd-party code. I regularly have problems with "can't find the graphic" or even ever-so-slightly-corrupted documents from users who played around with another word-processor.

    It's what happens in life.

    My solution is to have a pre-processor, written in WordVBA, that runs against a stored table of filenames, with a monitoring program (in Excel, FWIW) that issues a reboot if things are stalled waiting for me to get out of bed and tap the Enter key.
    I run this first phase overnight. Who cares how long it takes?
    In the morning I have a set of files that can be opened under program control - guaranteed - and another set that are "problem documents" for the client's advice.

  6. #6
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can I check for document protection? (Word XP)

    We had a similar problem, which is solved with a 2-step solution:
    1. <LI>In the template there's a CustomDocumentProperty "LNID" that's populated with the Lotus Notes mailaddress of the person that last saved the document. This is done during the Save command, which we hijacked for that purpose. If the batch process encounters a document that is protected with an unknown password, it's FullName and LNID-value are stored in a logfile.

      <LI>A Lotus Notes application, developed by a third party, reads the file and sends an e-mail with the protected file attached to the LNID mailbox, asking to return an unprotected version of the document. As the syntax of a LN application looks a lot like VB, I asked permission to publish the core of the code here, but that was denied.

Posting Permissions

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