如何使用DocumentFormat.OpenXml将Microsoft Word文档部分或段落设置为只读

时间:2017-05-25 14:12:12

标签: c# ms-word ms-office openxml openxml-sdk

有没有办法将ms word文档部分/段落设置为只能以编程方式读取?我知道限制只能在下面的链接所描述的单词中读取。 https://support.office.com/en-us/article/Restrict-or-permit-formatting-changes-69ca7857-db43-4785-9e14-7735db6d79bb

但是我需要在C#中执行此操作,因为我需要首先检查用户是否在SharePoint组中。

1 个答案:

答案 0 :(得分:0)

是的,有可能。

First extend your document:

Document extendedDocument = Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveDocument);

Then Protect it:

extendedDocument.Protect(Word.WdProtectionType.wdAllowOnlyReading, true, "password", true);

修改:see more about working with an IRM to more securely protect your documents

修改:see more about how to use the protect method: