Reputation: 75
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!
Upvotes: 1
Views: 285
Reputation: 25693
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
Application.Taskpanes(wdTaskPaneDocumentProtection).Visible = true
does not necessarily reset the behavior during a Word session.Upvotes: 2