We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Question about document.BuiltInDocumentProperties.Security

I have a Word document that I’m maniuplating with Aspose.Words and when I examine the documentBuiltInDocumentProperties.Security properties, the document is set as “ReadOnlyEnforced”.
I’ve also seen a doucument where the Security properties are set to “ReadOnlyRecommended”.
Where is that controlled in Word? I’ve looked at Review | Protect Document, but doesn’t appear to be the place where those settings are made. (I’ve also looked at Office | Prepare, but didn’t see the settings there either.)

Hi Mike,
Thanks for your inquiry. These options are set when you protect your document in MS Word.

  1. If you specify “Password to open” - BuiltInDocumentProperties.Security = PasswordProtected
  2. If you specify “Password to modify” - BuiltInDocumentProperties.Security = ReadOnlyEnforced
  3. If you check “Read-only recomended” checkbox - BuiltInDocumentProperties.Security = ReadOnlyRecommended
  4. And if you protect your document and allow only Comments - BuiltInDocumentProperties.Security = ReadOnlyExceptAnnotations

To protect your document select “Save as” from File menu, click “Tools” button in the bottom-left corner and select “General option”. Please see the screenshot.
Best regards.

Great explanation, Alexey. Many thanks.
I didn’t realize all those options were available from the “General Options” on the Save As dialog box.
One follow-up: is there any way to see these values from a document that has already been saved with these choices? I’m looking at a document now that was originally saved with “ReadOnlyEnforced”, but now looking at the “General Options”, you can’t tell that that setting was originally chosen.
Of course, Aspose.Words easily shows me that the setting was chosen when the file was saved.

Hi Mike,
Thanks for your inquiry. If the appropriate passwords are set, checkbox is checked or the appropriate protection type is set, you can be sure that these security options are set.
Best regards.

I hate to impose on you, but I have a Word document I’d like you to take a quick look at, if you would be so kind.
When I open the attached Word file, I’m not prompted for a password, nor do any settings appear on the Protect Document panel (on the Review ribbon).
However, when I open the file with Aspose.Words and inspect the BuiltInDocumentProperties.Security, it shows as “ReadOnlyEnforced”. How can this be?
I’m attaching the file in a separate thread where I can choose “Keep this post private”.

Here’s the link to the file in question…

Hi Mike,
Thank you for additional information. It seems MS Word did not reset value of this property. If you just open/save the document in MS Word, Aspose.Words returns DocumentSecurity.None.
Best regards.

That’s odd that Word does that.
Thanks again.

Hi Alexey,
After our conversation a few months ago, I thought this issue was behind me, but it’s still a bit of a problem for us.
Your suggestion of simply re-saving the Word template so that the “ReadOnlyEnforced” flag is reset only holds true if you resave the file as DOCX, at least in my experience.
I have one group of users who only have Word 2003, and they’ve built hundreds of templates, all of which have the “ReadOnlyEnforced” flag enabled (somehow), but amazingly, no password.
It would be very useful if Words had a boolean property for “HasPassword”, so at least I could distinguish between proper files that have both “ReadOnlyEnforce” and a password, from those that are “ReadOnlyEnforced” but NO password.
Would that be possible?

Hi Mike,
Thanks for your request. I think you should just use doc.WriteProtection.IsWriteProtected.

Document doc = new Document(@"Test001(ATF)_Fundings+Instructions+Broker±+Complete.doc");

Hope this helps.
Best regards.

That helps a lot – thank you. I didn’t see that property and it’s exactly what I needed.