Método ControlCollection.AddBuildingBlockGalleryContentControl (String)

Adiciona um novo BuildingBlockGalleryContentControl na seleção atual no documento.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word (em Microsoft.Office.Tools.Word.dll)

Sintaxe

'Declaração
Function AddBuildingBlockGalleryContentControl ( _
    name As String _
) As BuildingBlockGalleryContentControl
BuildingBlockGalleryContentControl AddBuildingBlockGalleryContentControl(
    string name
)

Parâmetros

Valor de retorno

Tipo: Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl
O BuildingBlockGalleryContentControl que foi adicionado ao documento.

Exceções

Exceção Condição
ArgumentNullException

nameé nulluma referência nula (Nothing no Visual Basic) ou tem comprimento zero.

ControlNameAlreadyExistsException

Um controle com o mesmo nome já está na ControlCollection.

Comentários

Use esse método para adicionar um novo BuildingBlockGalleryContentControl na seleção atual no documento no tempo de execução. For more information, see Adicionar controles a documentos do Office em tempo de execução.

Exemplos

O exemplo de código a seguir adiciona um novo BuildingBlockGalleryContentControl para o início do documento. O BuildingBlockGalleryContentControl exibe os blocos de construção equação fornecidos pelo Word de Microsoft Office.

Esta versão é para uma personalização em nível de documento. Para usar esse código, colá-lo na ThisDocument classe em seu projeto e a chamada a AddBuildingBlockControlAtSelection método a partir do ThisDocument_Startup método.

Dim buildingBlockGalleryControl1 As Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl

Private Sub AddBuildingBlockGalleryControlAtSelection()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.Select()
    buildingBlockGalleryControl1 = Me.Controls.AddBuildingBlockGalleryContentControl( _
        "buildingBlockGalleryControl1")
    With buildingBlockGalleryControl1
        .PlaceholderText = "Choose an equation"
        .BuildingBlockCategory = "Built-In"
        .BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations
    End With
End Sub
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;
}

Esta versão é um suplemento de nível de aplicativo que se destina a .NET Framework 4. Para usar esse código, colá-lo na ThisAddIn classe em seu projeto e a chamada a AddBuildingBlockControlAtSelection método a partir do ThisAddIn_Startup método.

Dim buildingBlockGalleryControl1 As BuildingBlockGalleryContentControl

Private Sub AddBuildingBlockGalleryControlAtSelection()
    If Me.Application.ActiveDocument Is Nothing Then
        Return
    End If

    Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
    vstoDoc.Paragraphs(1).Range.InsertParagraphBefore()
    vstoDoc.Paragraphs(1).Range.Select()
    buildingBlockGalleryControl1 = vstoDoc.Controls.AddBuildingBlockGalleryContentControl( _
        "buildingBlockGalleryControl1")
    With buildingBlockGalleryControl1
        .PlaceholderText = "Choose an equation"
        .BuildingBlockCategory = "Built-In"
        .BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations
    End With
End Sub
private Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl buildingBlockControl1;

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

    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    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;
}

Segurança do .NET Framework

Consulte também

Referência

ControlCollection Interface

Sobrecargas AddBuildingBlockGalleryContentControl

Namespace Microsoft.Office.Tools.Word

Outros recursos

Adicionar controles a documentos do Office em tempo de execução

Métodos auxiliares para controles de Host

Como: Adicionar controles de conteúdo para documentos do Word