Método ControlCollection.AddBuildingBlockGalleryContentControl (Range, String)

Adiciona um novo BuildingBlockGalleryContentControl no intervalo especificado no documento.

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

Sintaxe

'Declaração
Function AddBuildingBlockGalleryContentControl ( _
    range As Range, _
    name As String _
) As BuildingBlockGalleryContentControl
BuildingBlockGalleryContentControl AddBuildingBlockGalleryContentControl(
    Range range,
    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 em um intervalo especificado 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 AddBuildingBlockControlAtRange método a partir do ThisDocument_Startup método.

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

Private Sub AddBuildingBlockGalleryControlAtRange()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    buildingBlockGalleryControl2 = Me.Controls.AddBuildingBlockGalleryContentControl( _
        Me.Paragraphs(1).Range, "buildingBlockGalleryControl2")
    With buildingBlockGalleryControl2
        .PlaceholderText = "Choose an equation"
        .BuildingBlockCategory = "Built-In"
        .BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations
    End With
End Sub
private Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl buildingBlockControl2;

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

    buildingBlockControl2 = this.Controls.AddBuildingBlockGalleryContentControl(
       this.Paragraphs[1].Range, "buildingBlockControl2");
    buildingBlockControl2.PlaceholderText = "Choose an equation";
    buildingBlockControl2.BuildingBlockCategory = "Built-In";
    buildingBlockControl2.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 AddBuildingBlockControlAtRange método a partir do ThisAddIn_Startup método.

Dim buildingBlockGalleryControl2 As BuildingBlockGalleryContentControl

Private Sub AddBuildingBlockGalleryControlAtRange()
    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()
    buildingBlockGalleryControl2 = vstoDoc.Controls.AddBuildingBlockGalleryContentControl( _
        vstoDoc.Paragraphs(1).Range, "buildingBlockGalleryControl2")
    With buildingBlockGalleryControl2
        .PlaceholderText = "Choose an equation"
        .BuildingBlockCategory = "Built-In"
        .BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations
    End With
End Sub
private Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl buildingBlockControl2;

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

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

    buildingBlockControl2 = vstoDoc.Controls.AddBuildingBlockGalleryContentControl(
       vstoDoc.Paragraphs[1].Range, "buildingBlockControl2");
    buildingBlockControl2.PlaceholderText = "Choose an equation";
    buildingBlockControl2.BuildingBlockCategory = "Built-In";
    buildingBlockControl2.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