Wait a minute. I didn't say anything was "such a great thing." I simply
tried to offer you some alternatives that might work since what you suggest
and want doesn't?
As for getting serious attention from Microsoft on your suggestion I won't
hold my breathe. Hold yours if you want to but CCs are riddled with bugs as
it is. I doubt they will give serious attention to making them better
before they give some attention to making them work. From what I can't see
they aren't doing much about that.
I am not implying that you are not a serious, highly intelligent developer.
I'm neither, but I have spent many, many hours trying make something useful
out of ContentControls and this could be a stretch but perhaps you don't
understand them as well as you think.
What do you mean by "can't be assigned a name/ID and then referenced that
way?" and "You have to loop through all of them in the doc or table or
wherever?".
We both know it can't be assigned an ID (your losing sleep over it and I
don't care) but it can certainly be assigned a name (If you are willing to
let a title be a name.)
Sub AddTitledCC()
Dim oCC As ContentControl
Set oCC = ThisDocument.ContentControls.Add(wdContentControlText,
Selection.Range)
oCC.Title = "CCTitle"
End Sub
Fair enough?
Then:
Sub ReferenceCCByTitle()
ThisDocument.SelectContentControlsByTitle("CCTitle").Item(1).Range.Text =
"Did this not reference the title"
End Sub
Is that not referencing the CC by name in code?
As you know the a you can have multiple CCs with the same title. If that is
the case then if you want to want to work with one of them (any of them my
title) then you have to include its Item index.
If you had 15 different CCs titled "myName" then it seems you would want all
of them to contain the same data. After all, my name is Greg if it appears
on the first page or last page of a document and I assume yours wouldn't
chang between pages. If that is the case then the all the myName CCs should
be mapped to customXML so that if you change one with code then they all
change.
I do. Unfortunately, you can't direct reference a CC using it's
title. You have to loop through all of them in the doc or table or
wherever. And besides that, the CC.Title doesn't have to be unique.
You can have 15 different CC's all titled "myName". I don't
understand why you think the way it is is such a great thing. As far
as I know, a ContentControl is the only (or one of the very, very
few) objects that . This was just a suggestion to MS to make CC's as easy
to
use as other objects.
I really would like to know why you believe the way CC's are assigned
a number ID is good and how it benefits the developer.
--
Greg Maxey - Word MVP
My web site
http://gregmaxey.mvps.org
McCain/Palin '08 !!!