简体   繁体   English

避免看到“限制编辑”侧边栏 - MS WORD

[英]Avoid seeing “restrict editing” sidebar - MS WORD

I created a template and then restricted the editing to specific areas.我创建了一个模板,然后将编辑限制在特定区域。

I added a simple macro to avoid seeing the yellow highlighting我添加了一个简单的宏以避免看到黄色突出显示

ActiveWindow.View.ShadeEditableRanges = False

Now I want to avoid that when a user tries to modify a restricted area, the "Restricted Editing" sidebar appears.现在我想避免当用户尝试修改受限区域时,会出现“受限编辑”侧栏。

I recorded a macro to see what instructions VBA reads, but there is no command to open the sidebar...我录制了一个宏来查看 VBA 读取的指令,但是没有打开侧边栏的命令...

Do you think there is a way to avoid the sidebar appearing?您认为有没有办法避免出现侧边栏? If I was in excel, I would think about something like:如果我在 excel 中,我会考虑类似的事情:

 Private Sub RestricEditing_Change(ByVal Target As Range)
' Determine whether the change is in the restricted editing area
   Set checkRange = Application.Intersect(Target, restricted area)

' If the change wasn't in this range then we're done
   If checkRange Is Nothing Then Exit Sub
   Else "do not show the restricted editing sidebar"

Thanks in advance to all of you!在此先感谢大家!

When I use the following, the taskpane appears to be "disabled" for the user.当我使用以下内容时,任务窗格似乎对用户“禁用”。 It can still be shown via the "Restrict Editing" button in the Developer tab of the Ribbon:它仍然可以通过功能区的“开发人员”选项卡中的“限制编辑”按钮显示:

Application.Taskpanes(wdTaskPaneDocumentProtection).Visible = False

To "disable" this pane when the document is opened I've had to resort to some trickery - and the pane in question will be visible for a moment.要在打开文档时“禁用”此窗格,我不得不采取一些技巧 - 有问题的窗格将暂时可见。 This assumes that the very start of the document should not be editable.这假设文档的开头不应该是可编辑的。 SendKeys will trigger the pane; SendKeys将触发窗格; the disable is called on a timer.在计时器上调用禁用。

Sub AutoOpen()
    Application.ScreenUpdating = False
    ActiveWindow.View.ShadeEditableRanges = False
    SendKeys "T"
    DoEvents
    Application.OnTime Now + TimeValue("00:00:01"), "DisableProtectionPane"
End Sub

Sub DisableProtectionPane()
    Application.TaskPanes(wdTaskPaneDocumentProtection).Visible = False
End Sub

I note that我注意到

  • when the user dismisses the taskpane by clicking the "x" at the top right, the behavior is the same as using the above code.当用户通过单击右上角的“x”关闭任务窗格时,行为与使用上述代码相同。
  • both this setting and that of the highlighting are reset to default when the document is closed and opened again.当文档关闭并再次打开时,此设置和突出显示的设置都将重置为默认值。
  • that using Application.Taskpanes(wdTaskPaneDocumentProtection).Visible = true does not necessarily reset the behavior during a Word session.使用Application.Taskpanes(wdTaskPaneDocumentProtection).Visible = true不一定会在 Word 会话期间重置行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM