Thread: [Solved] Content control titles
View Single Post
 
Old 05-29-2012, 06:11 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,341
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

AFAIK, the only way to use the title directly is to loop through the collection:
Code:
Dim CCtrl As ContentControl
For Each CCtrl In ActiveDocument.ContentControls
  If CCtrl.Title = "My Title" Then
    'do something
  End If
Next
If you were doing a lot of Content Control processing in code, rather than interactively, you might get a performance improvement if you store the collection in code first:
Code:
Sub Demo()
Dim CCtrlSet As Variant, CCtrl As ContentControl
Set CCtrlSet = ActiveDocument.ContentControls
For Each CCtrl In CCtrlSet
  If CCtrl.Title = "My Title" Then
    'do something
  End If
Next
Set CCtrlSet = Nothing
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote