Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-23-2018, 03:35 PM
macropod's Avatar
macropod macropod is offline Lock All Content Controls, Except the First Instance of Each Title Windows 7 64bit Lock All Content Controls, Except the First Instance of Each Title Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

It seems to me you could manage any number of such content controls via code like:


Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
Application.ScreenUpdating = False
Dim i As Long
With ActiveDocument.SelectContentControlsByTitle(CCtrl.Title)
  For i = 2 To .Count
    With .Item(i)
      .LockContents = False
      .Range.Text = CCtrl.Range.Text
      .LockContents = True
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 09-27-2018, 09:28 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

Unfortunately, I can't seem to get this code to do anything.

Quote:
Originally Posted by macropod View Post
It seems to me you could manage any number of such content controls via code like:
Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
Application.ScreenUpdating = False
Dim i As Long
With ActiveDocument.SelectContentControlsByTitle(CCtrl.Title)
  For i = 2 To .Count
    With .Item(i)
      .LockContents = False
      .Range.Text = CCtrl.Range.Text
      .LockContents = True
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub
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 11:51 AM.


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