编程Word 2010 [英] Programming Word 2010

查看:104
本文介绍了编程Word 2010的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们想在整个Word 2010文档中以代码形式实施和删除不同类型的文档保护(限制编辑).
我们的代码已在Word的早期版本中使用,但不再与新版本一起使用.从
更改保护类型时 wdAllowOnly对wdAllowOnlyFormFields的修订,我们的代码旨在取消保护文档,然后使用新的
保护它 保护类型如下.

ProtectioType = ActiveDocument.ProtectionType
如果ProtectioType = wdAllowOnlyRevisions,则
ActiveDocument.Unprotect()
ActiveDocument.Protect(密码:="xxxxx",NoReset:=正确,类型:= wdAllowOnlyFormFields,UseIRM:= False,EnforceStyleLock:= False)
如果结束

执行ActiveDocument.Unprotect之后,ActiveDocument.ProtectionType变为-1,这是正确的.但是在文件
限制编辑"窗格(从文档功能区菜单查看"->限制编辑")未更改.
"2.只允许在文档中进行这种类型的"仍选中已完成的更改"复选框.因此,
执行代码ActiveDocument.Protect时,不应用wdAllowOnlyFormFields保护类型,并且保留wdAllowOnlyRevisions.

但是,在用代码取消保护文档之后,并在用代码调用保护方法之前,
仍选中"2.只允许在文档中进行这种类型的"复选框(在审阅->限制
文档功能区菜单中的编辑"面板).结果,使用代码时,该文档未得到我们想要的保护.

我们可以使用任何VBA/Word功能来以编程方式清除限制编辑"面板中的复选框吗?非常感谢!

We would like to enforce and remove different types of Document Protection (Restrict Editing) on a whole Word 2010 document in code.
Our code has worked in previous version of Word but is no longer working with the new version. When changing protection type from
wdAllowOnlyRevisions to wdAllowOnlyFormFields, our code is designed to unprotect the document and then protect it with a new
protection type as follows.

ProtectioType = ActiveDocument.ProtectionType
If ProtectioType = wdAllowOnlyRevisions Then
ActiveDocument.Unprotect()
ActiveDocument.Protect(Password:="xxxxx", NoReset:=True, Type:= wdAllowOnlyFormFields, UseIRM:=False, EnforceStyleLock:=False)
End If

After ActiveDocument.Unprotect executed, ActiveDocument.ProtectionType becomes -1 which is correct. But in the document
the Restrict Editing pane (From the document ribbon menu Review -> Restrict Editing) settings are not changed. The
"2. Allow only this type of editing in the document:" checkbox is still checked for "Tacked changes". Therefore,
when code ActiveDocument.Protect is executed, wdAllowOnlyFormFields protection type is not applied and it keeps wdAllowOnlyRevisions.

However, after unprotecting the document in code and before calling the protect method in code,
the "2. Allow only this type of editing in the document:" checkbox is still checked (in the Review->Restrict
Editing panel in the ribbon menu of the document). As the result, the document is not protected as we want it to be when using the code.

Are there any VBA/Word functions we can use to programmatically clear that checkbox in the Restrict Editing panel? Many thanks!

推荐答案

我没有MS Word 2010,但是我发现了一篇有趣的文章.阅读 [
I don''t have MS Word 2010, but i found interesting article. Read this[^] article, a specially, the section: "Applies to".


这篇关于编程Word 2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆