Insert a Content Control into a Building Block
Building blocks and content controls are extremely flexible. You can create building blocks that contain content controls, or you can create content controls that use building blocks to present rich content selections to the user. This topic shows how to insert a content control into a building block, which users can then insert into their documents.
The objects used in this sample are:
The following code inserts a content control into the active document, and then adds the content control to the collection of building blocks in the template attached to the active document.
Sub InsertContentControlIntoBuildingBlock()
Dim objCC As ContentControl
Dim objBB As BuildingBlock
Dim objTemplate As Template
Dim objRange As Range
Set objTemplate = ActiveDocument.AttachedTemplate
Set objCC = ActiveDocument.Range.ContentControls _
.Add(wdContentControlComboBox)
objCC.DropdownListEntries.Add "Outstanding"
objCC.DropdownListEntries.Add "Good"
objCC.DropdownListEntries.Add "Fair"
Set objRange = ActiveDocument.Range
Set objBB = objTemplate.BuildingBlockEntries.Add("OGF Rating Scale", _
wdTypeCustom1, "Ratings", objRange)
End Sub
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.