![]() |
|
#1
|
|||
|
|||
|
Rather than refer to my content controls as .contentcontrol(3) (for example) and I refer to them by the title I have given them.
In some of my documents I have about 100 content controls and using numbers is rather difficult to read. Thanks |
|
#2
|
||||
|
||||
|
Is there an issue here?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
Sorry, failed to explain.
I give each of my content controls a title in the properties. Is it possible for me to update these using the title rather than the number. eg I currently have field = activedocument.contentcontrols(1).range.text what I want to do is field = activedocument.contentcontrols("title").range.text But, this doesn't work. Is this possible, and if so what should the syntax be. Thanks |
|
#4
|
||||
|
||||
|
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
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] |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Move to next content control
|
cksm4 | Word VBA | 13 | 07-02-2019 07:48 PM |
Rich Text Content Control - Allow User Formatting
|
keithacochrane | Word | 1 | 05-28-2012 05:06 PM |
| Retrieving content control value | jillapass | Word VBA | 4 | 05-24-2012 05:07 AM |
content control Word 2007
|
TessaLee | Word | 1 | 03-11-2011 12:51 AM |
| Templates: automatic text generation from Rich Text content control | Chickenmunga | Word | 0 | 10-01-2008 11:16 AM |