Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-27-2018, 09:33 PM
Guessed's Avatar
Guessed Guessed 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
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,185
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Greg's code is very elegant with the use of a Collection to determine if the code has already hit one of those CCs but it does rely on your consistent usage of the Title property for every CC.



An alternative to consider would be to just lock the CCs which are mapped to the same xpath as already used. There is also no real need to do two passes...
Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey, http://gregmaxey.com/word_tips.html, 9/27/2018
Dim oCC As ContentControl, oCol As New Collection
  On Error Resume Next
  For Each oCC In ActiveDocument.ContentControls
    If aCC.XMLMapping.IsMapped then oCol.Add oCC.XMLMapping.XPath, oCC.XMLMapping.XPath
    oCC.LockContents = Not Err.Number = 0
    Err.Clear
  Next oCC
lbl_Exit:
  Exit Sub
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
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 08:53 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