How do determine if a document is password protected

How can I tell whether a Word document is password-protected or not? I understand that the doc.BuiltInDocumentProperties.Security propery isn’t necessarily accurate because Microsoft doesn’t alway set this property. Are there any viable alternatives?
Jim McFadden / Unum


Thanks for your request.

  1. If you specify “Password to open” - BuiltInDocumentProperties.Security = PasswordProtected
    You should check LoadFormat using DetectFileFormat method:
    If returned format is OoxmlEncrypted or DocEncrypted then the document is PasswordProtected.

  2. If you specify “Password to modify” - BuiltInDocumentProperties.Security = ReadOnlyEnforced
    In this case you can use WriteProtection property to retrieve this protection status:

  3. If you check “Read-only recommended” checkbox - BuiltInDocumentProperties.Security = ReadOnlyRecommended

  4. And if you protect your document and allow only Comments - BuiltInDocumentProperties.Security = ReadOnlyExceptAnnotations
    In these two cases you can use Document.ProtectionType property:

Best regards,