使用 VBA 将文本段落设为只读 (Microsoft Word 2003)
有没有办法使用 VBA 将 Microsoft Word 2003 文档中的段落设为只读?
Is there a way to make a paragraph in a Microsoft Word 2003 document readonly using VBA?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为您只能通过选择不受保护的段落来做到这一点。
下面是一个示例宏,它选择一段文本,使其能够编辑,然后锁定文档的其余部分。 您可以使用 IRM 或密码保护,下面的宏使用后者。 您应该用更优雅的方法替换下面的选择方法
I think you can only do it by selecting the paragraphs that will not be protected.
Below is a sample macro that is selecting a piece of text, enabling it for editing, and then locking the rest of the document. You can either use IRM or password protection, the macro below is using the latter. You should replace the method of selection below by something more elegant
您可以通过将要保护的文本放入文本表单并对其进行保护来做到这一点。 显然有点恶心。
You might be able to do it by throwing the to-be-protected text into a text form and protecting that. Obviously a little gross.
上面的答案将留下黄色突出显示的可编辑区域。
一种替代方法是添加此 AutoOpen 代码
在Word 2007(已测试)中,更直接的方法是创建富文本内容控件并设置属性。 这将很容易使段落只读而不做任何突出显示。
更多 ContentControl.LockContentControl 属性
https://msdn.microsoft.com/en-us/library/office /ff835775.aspx
希望这可以帮助有同样头痛的人! :D
The answer above will leave a yellow highlighting of the editable area.
One alternative is adding this AutoOpen code
http://answers.microsoft.com/en-us/office/forum/office_2010-word/remove-highlighting-in-editable-areas-of-protected/bfe22585-c5d3-4c19-997f-092fc4aaaa7a
In Word 2007(tested), a more direct way is to create a rich text content control and set the properties. This will easily make a paragraph read-only without making any highlights.
More ContentControl.LockContentControl Property on
https://msdn.microsoft.com/en-us/library/office/ff835775.aspx
Hope this help anyone having the same headache! :D