Export (0) Print
Expand All

BuildingBlockGalleryContentControl.BuildingBlockCategory Property (2007 System)

Updated: July 2008

Gets or sets the category of the building blocks that are displayed in the BuildingBlockGalleryContentControl.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v9.0 (in Microsoft.Office.Tools.Word.v9.0.dll)

public string BuildingBlockCategory { get; set; }

Property Value

Type: System.String
The category of the building blocks that are displayed in the BuildingBlockGalleryContentControl.

All building blocks belong to a category and a gallery. Use the BuildingBlockCategory property to specify the category of the building blocks that are displayed by the BuildingBlockGalleryContentControl. You can set the value of this property to the Built-In or General categories defined by Microsoft Office Word, or you can specify a custom category.

To specify which gallery of building blocks to display in the BuildingBlockGalleryContentControl, use the BuildingBlockType property.

The following code example adds a new BuildingBlockGalleryContentControl to the beginning of the document. The BuildingBlockGalleryContentControl displays equation building blocks that are provided by Microsoft Office Word. The example sets the BuildingBlockCategory property to the Built-In category.

This version is for a document-level customization. To use this code, paste it into the ThisDocument class in your project, and call the AddBuildingBlockControlAtSelection method from the ThisDocument_Startup method.

private Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl buildingBlockControl1;

private void AddBuildingBlockControlAtSelection()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    this.Paragraphs[1].Range.Select();

    buildingBlockControl1 = this.Controls.AddBuildingBlockGalleryContentControl(
        "buildingBlockControl1");
    buildingBlockControl1.PlaceholderText = "Choose an equation";
    buildingBlockControl1.BuildingBlockCategory = "Built-In";
    buildingBlockControl1.BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations;
}

This version is for an application-level add-in. To use this code, paste it into the ThisAddIn class in your project, and call the AddBuildingBlockControlAtSelection method from the ThisAddIn_Startup method.

private Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl buildingBlockControl1;

private void AddBuildingBlockControlAtSelection()
{
    if (this.Application.ActiveDocument == null)
        return;

    Document vstoDoc = this.Application.ActiveDocument.GetVstoObject();
    vstoDoc.Paragraphs[1].Range.InsertParagraphBefore();
    vstoDoc.Paragraphs[1].Range.Select();

    buildingBlockControl1 = vstoDoc.Controls.AddBuildingBlockGalleryContentControl(
        "buildingBlockControl1");
    buildingBlockControl1.PlaceholderText = "Choose an equation";
    buildingBlockControl1.BuildingBlockCategory = "Built-In";
    buildingBlockControl1.BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations;
}

Date

History

Reason

July 2008

Added a version of the code example for an application-level add-in.

SP1 feature change.

Community Additions

ADD
Show:
© 2015 Microsoft