Type of Content Control

J

JenC

I am developing a template and have inserted several content controls.
However, they all look the same.

Is there a way to tell what kind of content control I've added (e.g., rich
text vs. plain text)? And is there a way to change from one type to another?
I'm thinking of MS Access, where you have the ability to change a control to
another type.

Thanks,
Jen
 
J

Jay Freedman

JenC said:
I am developing a template and have inserted several content controls.
However, they all look the same.

Is there a way to tell what kind of content control I've added (e.g.,
rich text vs. plain text)? And is there a way to change from one type
to another? I'm thinking of MS Access, where you have the ability to
change a control to another type.

Thanks,
Jen

Hi Jen,

They don't really *all* look the same. The rich text and plain text ones
look identical to each other, and the list box and combo box look the same
as each other. But yes, it is hard to tell at a glance.

One way to find what kind a particular text control is: Click inside it,
then click the Properties button in the Controls group. The label of the
third section of the dialog says either "Plain Text Properties" or "Rich
Text Properties". Unfortunately, even that doesn't work to tell a list box
from a combo box, since their Properties dialogs look the same, too. The
only practical difference is that you can type into a combo box but not into
a list box.

VBA knows, though. You can put this macro in a global template and add a
button for it to the Quick Access Toolbar.

Sub ShowCCType()
Dim CCs As ContentControls
Dim strType As String

Set CCs = Selection.Paragraphs(1).Range.ContentControls
If CCs.Count > 0 Then
Select Case CCs(1).Type
Case wdContentControlRichText
strType = "Rich Text"
Case wdContentControlText
strType = "Plain Text"
Case wdContentControlPicture
strType = "Picture"
Case wdContentControlComboBox
strType = "Combo Box"
Case wdContentControlDropdownList
strType = "Dropdown List"
Case wdContentControlDate
strType = "Date Picker"
Case wdContentControlBuildingBlockGallery
strType = "Building Block Gallery"
Case Else
strType = "other"
End Select

MsgBox "This is a " & strType & " content control."
End If
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
J

Jay Freedman

Hi Jen,

I forgot to answer your second question.

You can change the type of a content control by macro code, within limits.
For example,

ActiveDocument.ContentControls(1).Type = wdContentControlRichText

The help topic for the Type property of a content control explains:

"You can use the Type property to change the type of a content control from
one type to another. However, the ability to change the type of control
depends on the original type and on the content inside the content control
at the time of the change. All content controls can be changed to rich text
or building block gallery type content controls because these types allow
arbitrary content. For other types, if the content is valid for the type
that you want to change to, then changing the type is allowed. Otherwise,
the change is rejected, resulting in a run-time error."

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
J

JenC

Thanks Jay - this (and your previous message) is exactly what I was looking
for.

Jen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top