This documentation is archived and is not being maintained.

Inserting a Word 2007 Content Control into a Building Block

Office 2007

Office Visual How To

Applies to: 2007 Microsoft Office System, Microsoft Office Word 2007


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. In this video, you learn how to programmatically create a content control, and then how to programmatically add that content control to an entry in a building block gallery.

Code It

The following objects are used in this example:

The following example 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.

private void InsertContentControlIntoBuildingBlock()
  //Variable for the new content control.
  Word.ContentControl objCC;

  objCC = Application.ActiveDocument.
    ref missing);

    .Add("Outstanding", "Outstanding", 1);
    .Add("Good", "Good", 2);
    .Add("Fair", "Fair", 3);

  //Variables for the building block.
  Word.Template objTemplate;
  Word.BuildingBlock objBB;
  Word.Range objRange;

  objTemplate = (Word.Template)Application
  objRange = Application.ActiveDocument
  objBB = objTemplate.BuildingBlockEntries
    .Add("OGF Rating Scale",
    "Building Blocks", objRange, ref missing,
Read It

You can also create content controls that use building blocks to display rich text to the user. For more information about how to do this, see the next video in this series: Filtering the Building Block List in a Word 2007 Content Control.

See It

Video splash screen

Watch the Video

Video Length: 00:03:11

File Size: 3.9 MB WMV

Explore It