word interop changes格式保护文档中的限制 [英] word interop changing Formatting Restriction within protect document
问题描述
我们有一个用c#编写的Office Automation来包含特定Section中的数据。在Word文档中插入数据后,我们会保护添加数据的部分。为此,我们使用以下代码=>
we have an Office Automation written in c# to include data in a specific Section. After we insert the data in the Word document we protect the section where we added the Data. To do this we use the following code =>
WordEngine wemain =...
...
wemain.ProtectDocument(Microsoft.Office.Interop.Word.WdProtectionType.wdAllowOnlyFormFields, bFalse, szPassword, bFalse, bFalse);
所有这一切都正常。
现在问题是客户希望能够在受保护的文件中打开和关闭行号。为此,我看到Microsoft在限制编辑对话框中提供设置=>格式限制。
Problem now is that the Customer wants to be able to turn the Line Numbering on and off in the protected File. For this I saw that Microsoft offers Settings in the Restrict Editing Dialog => Formatting Restriction.
有谁知道如何通过互操作改变这个?
Does anyone knows how I can change this via interop?
最好的问候
Michael
MK
推荐答案
Hi MK,
Hi MK,
>>为此,我看到Microsoft在限制编辑对话框中提供设置=>格式限制。
>> For this I saw that Microsoft offers Settings in the Restrict Editing Dialog => Formatting Restriction.
您的意思是要为预计文档设置格式限制吗?如果是这样,我认为你需要取消保护,然后设置它并再次保护文档。
Do you mean you want to set formatting restrictions for a projected document? If so, I think you need to unprotect it, then set it and protect the documents again.
这是VBA中的一个简单代码:
Here is a simple code in VBA:
ActiveDocument.Unprotect Password:="123"
ActiveDocument.Styles("Body Text").Locked = True
ActiveDocument.Styles("Body Text 2").Locked = False
ActiveDocument.Protect Password:="123", NoReset:=False, Type:= _
wdNoProtection, UseIRM:=False, EnforceStyleLock:=True
如果您在实现这些代码时遇到任何问题互操作,请随时告诉我们。
If you have any trouble to achieve these code by interop, please feel free to let us know.
最好的问候,
Edward
这篇关于word interop changes格式保护文档中的限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!