Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-27-2018, 09:25 AM
therexjones therexjones is offline Lock All Content Controls, Except the First Instance of Each Title Windows 10 Lock All Content Controls, Except the First Instance of Each Title Office 2016
Novice
Lock All Content Controls, Except the First Instance of Each Title
 
Join Date: Sep 2018
Posts: 6
therexjones is on a distinguished road
Default

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 View Post
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.
Reply With Quote
Reply

Tags
content control, instance, title



Similar Threads
Thread Thread Starter Forum Replies Last Post
Lock All Content Controls, Except the First Instance of Each Title Word VBA : Lock the content of a table cell User75 Word Tables 3 06-26-2018 05:37 AM
Macro to save docx to doc that checks compatibility and converts content controls to static content. staicumihai Word VBA 4 10-12-2016 08:23 PM
Lock All Content Controls, Except the First Instance of Each Title Lock top row, so column title is always visible Susanma Excel 1 03-30-2015 01:50 AM
VBA for content controls ciresuark Word VBA 1 03-10-2015 03:14 PM
Lock All Content Controls, Except the First Instance of Each Title Creating a plain text content control for every instance of a word or phrase RobsterCraw Word VBA 16 11-20-2012 03:25 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:47 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft