Word 用宏命令实现锁定页眉页脚的两种方式

方式一:

Sub protHeader()
'取消保护
If Not ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Unprotect (“123456”)
End If
Dim currentSection As Section
'如果只有1节就在最前面插入一个连续分节符
If ActiveDocument.Sections.Count = 1 Then
Selection.HomeKey Unit:=wdStory
Selection.InsertBreak Type:=wdSectionBreakContinuous
End If
'将所有节设置为不选中
For Each currentSection In ActiveDocument.Sections
currentSection.ProtectedForForms = False
Next
'保护起来
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect Type:=WdProtectionType.wdAllowOnlyFormFields, Password:=”123456″, NoReset:=True, EnforceStyleLock:=False
End If
End Sub

 

方式二:

Sub protWithoutMain()
'取消保护
If Not ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Unprotect (“123456789”)
End If
'选中整篇文章
Selection.WholeStory
'将整篇文章的例外项设置为每个人
Selection.Editors.Add wdEditorEveryone
'保护起来
ActiveDocument.Protect Password:=”123456″, NoReset:=True, Type:= _
wdAllowOnlyReading, UseIRM:=False, EnforceStyleLock:=False
'取消全选,将光标移至文章开头
Selection.HomeKey Unit:=wdStory
End Sub

总结:
方式一不能添加批注、不能添加/修改编号、可以删除页眉页脚
方式二可以添加批注、可以添加/修改编号、不可以删除页眉页脚
在可进行的操作方面还有其他一些细微差别,各有所长。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值