Question

how i caon make a wordml read-only from .

any ideas??

Was it helpful?

Solution

Adding the following to your WordML document will tell Word to treat its contents as read only:

<w:wordDocument>
  <w:docPr>
    <w:documentProtection w:edit="read-only" w:enforcement="on" w:unprotectPassword="5349CC3D"/>
  </w:docPr>
</w:wordDocument>

w:unprotectPassword is "1234" in this example but this attribute is not required. If an unlock password is not included Word will allow the user to just turn the read only state of the document off without challenging them.

Hope that helps and is what you are looking for!

OTHER TIPS

if you are using the Open XML SDK 2.0 you can specify a file as read-only in the second parameter to the open method call:

// false is the read-only property
using (var wordprocessingDocument = WordprocessingDocument.Open(documentFileName, false))
{
     // Do work here            
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top