Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-29-2012, 04:01 AM
jillapass jillapass is offline Content control titles Windows 7 32bit Content control titles Office 2007
Novice
Content control titles
 
Join Date: Dec 2011
Posts: 26
jillapass is on a distinguished road
Default Content control titles

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
Reply With Quote
  #2  
Old 05-29-2012, 05:31 AM
macropod's Avatar
macropod macropod is offline Content control titles Windows 7 64bit Content control titles Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

Is there an issue here?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-29-2012, 05:56 AM
jillapass jillapass is offline Content control titles Windows 7 32bit Content control titles Office 2007
Novice
Content control titles
 
Join Date: Dec 2011
Posts: 26
jillapass is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 05-29-2012, 06:11 AM
macropod's Avatar
macropod macropod is offline Content control titles Windows 7 64bit Content control titles Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Content control titles Move to next content control cksm4 Word VBA 13 07-02-2019 07:48 PM
Content control titles 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 titles 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

Other Forums: Access Forums

All times are GMT -7. The time now is 06:09 PM.


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