0

I'm trying to programmatically update the text of some content controls, based on another control. I'm getting the following error:

"Run time error 6124. You are not allowed to edit this selection because it is protected".

Here's my code so far:

Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)

Select Case ContentControl.Title
    Case "Party"
        Call CascadeParty(ContentControl)
End Select

End Sub



Sub CascadeParty(ByVal cControl As ContentControl)

Dim con As ContentControl

For Each con In ActiveDocument.ContentControls
    If con.Title = "Party" Then
        con.Range.Text = cControl.Range.Text ' ERROR HERE
    End If
Next con

End Sub

I've also tried passing a string instead of the control, same problem. None of the answers on this similar post helped. The document is not protected in any way and none of the content controls are locked.

Any ideas? Thanks.

UPDATE: I've tried my code in a fresh clean document and it works fine, so it's something about the document I've been given. Again, nothing is protected so I'm still at a loss.

Community
  • 1
  • 1
Absinthe
  • 3,258
  • 6
  • 31
  • 70

1 Answers1

1

"Protected" probably means that the ContentControl is set to "Cannot Edit". Right before you say "con.range.text = ...", put in a line that says "con.LockContents = False". Right after that, you probably want to set con.LockContents back to True.

Top-Master
  • 7,611
  • 5
  • 39
  • 71
Bruce M
  • 119
  • 9