简体   繁体   中英

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...

Do you think there is a way to avoid the sidebar appearing? If I was in excel, I would think about something like:

 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; 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.
  • 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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