My content controls are already mapped as such. I'm looking for code to change the "Contents cannot be edited" property for only specific instances of each mapped content control.
I'm using the following codes to lock or unlock all of the fields at once, but then I have to go back and manually unlock only the fields I want to be editable by the end user. None of this really applies to the published template, it's just to make it simpler for me to make changes on the back end without so much repetition. What I can't figure out is how to modify the code so it only applies to a specific instance of a given Title or Tag.
Code:
Sub UnlockAllFormFields()
' Remove editing restrictions from all content controls
Application.ScreenUpdating = False
Dim objCC As ContentControl
' Loop through and select all content controls
For Each objCC In ActiveDocument.ContentControls
' Un-check "Contents cannot be edited" box
objCC.LockContents = False
Next
Application.ScreenUpdating = True
End Sub
Sub LockAllFormFields()
' Remove editing restrictions from all content controls
Application.ScreenUpdating = False
Dim objCC As ContentControl
' Loop through and select all content controls
For Each objCC In ActiveDocument.ContentControls
' Un-check "Contents cannot be edited" box
objCC.LockContents = True
Next
Application.ScreenUpdating = True
End Sub
Quote:
Originally Posted by gmayor
From the description it seems that you are duplicating content controls to repeat values throughout the document. That being the case, why don't you use mapped controls to repeat the data? Then whatever is entered in one of them is repeated in the others so that the need to lock and unlock and thus the need for a macro seems moot.
https://www.gmayor.com/insert_content_control_addin.htm makes it even simpler to insert mapped content controls. Insert the first one then copy and paste it to the other locations.
|