开发者

make wordml readonly

开发者 https://www.devze.com 2023-01-16 16:05 出处:网络
开发者_开发技巧how i caon make a wordml read-only from . any ideas??Adding the following to your WordML document will tell Word to treat its contents as read only:
开发者_开发技巧

how i caon make a wordml read-only from .

any ideas??


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!


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            
}
0

精彩评论

暂无评论...
验证码 换一张
取 消