我有一个Word (2010)宏断开链接,并将保护设置为只读。
If ActiveDocument.ProtectionType <> wdNoProtection Then ActiveDocument.Unprotect Password:="“End If
Selection.WholeStory
Selection.Fields.Unlink
Selection.StartOf
ActiveDocument.Protect Password:="", NoReset:=False, Type:= _
wdAllowOnlyReading, UseIRM:=False, EnforceStyleLock:=False文档仅作为表单域打开,并包含一些复选框。当我运行宏并保存对文档所做的更改时,即使在保存前选中保护状态为只读,它也只能作为表单域重新打开。
奇怪的是,当我将保护设置为手动只读并保存时,只读属性仍然存在。
你知道为什么会发生这样的事情吗?
发布于 2013-02-11 06:10:04
NoReset:=False选项意味着表单将只打开表单域...-换句话说,它将删除表单中的所有内容。如果这不是您想要的,则需要设置NoReset:=True。
发布于 2013-07-30 23:07:10
尝试此操作以使您的文档为只读:
Private Sub CommandButton1_Click()
Dim sPassword As String
sPassword = "YourPasswordHere"
.Protect NoReset:=True, _
Password:=sPassword, _
Type:=wdAllowOnlyReading
End With
End Sub然后,您可以使用在代码中输入的密码通过developer选项卡取消对文档的保护。
发布于 2014-04-01 13:44:16
Sub Test2()
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Unprotect
End If
End Subhttps://stackoverflow.com/questions/14803124
复制相似问题