none
How to check if a word document is write protected? RRS feed

  • Question

  • I am writing Outlook addin which check if the word attachment is password protected or not . It should check both password i.e. password to open the document and to modify(write) the docuemnt. I'm making use of Microsoft.office.interop.word dll and Office 2007
    The issue is  - When I call Open Method on documents object  to open a word document which is write protected  and pass nothing /any value for write password document, it still opens the word document but ideally it should fail and give some kind of exception that the provided password is not correct. Otherwise how can I check programatically check if a word document is write protected. any pointer if I'm making some mistake .

    Word.

    Document doc = docs.Open(ref file, ref missing, ref isReadonly, ref missing, ref pwd, ref missing, ref missing, ref wPws,

     

    ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);

     

    Tuesday, February 16, 2010 10:10 AM

Answers

  • Hello Kapilg,

    There is a property of Document object named WriteReserved which presents if the specified document is protected with a write password. For this, please refer to this MSDN page: http://msdn.microsoft.com/en-us/library/bb257531.aspx.

    If you have any further question, please feel free to follow up.

    Best regards,
    Bessie

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Bessie Zhao Monday, February 22, 2010 9:17 AM
    Sunday, February 21, 2010 5:41 AM