ControlCollection.AddBuildingBlockGalleryContentControl-Methode (String)

Fügt bei der aktuellen Auswahl im Dokument ein neues BuildingBlockGalleryContentControl hinzu.

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

Syntax

'Declaration
Function AddBuildingBlockGalleryContentControl ( _
    name As String _
) As BuildingBlockGalleryContentControl
BuildingBlockGalleryContentControl AddBuildingBlockGalleryContentControl(
    string name
)

Parameter

Rückgabewert

Typ: Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl
Das BuildingBlockGalleryContentControl, das dem Dokument hinzugefügt wurde.

Ausnahmen

Ausnahme Bedingung
ArgumentNullException

name ist nullNULL-Verweis (Nothing in Visual Basic) oder hat die Länge 0 (null).

ControlNameAlreadyExistsException

Ein Steuerelement mit dem gleichen Namen ist bereits in der ControlCollection vorhanden.

Hinweise

Verwenden Sie diese Methode, um bei der aktuellen Auswahl im Dokument zur Laufzeit ein neues BuildingBlockGalleryContentControl hinzuzufügen. Weitere Informationen finden Sie unter Hinzufügen von Steuerelementen zu Office-Dokumenten zur Laufzeit.

Beispiele

Im folgenden Codebeispiel wird am Anfang des Dokuments ein neues BuildingBlockGalleryContentControl hinzugefügt. Das BuildingBlockGalleryContentControl zeigt Formelbausteine an, die von Microsoft Office Word bereitgestellt werden.

Diese Version bezieht sich auf eine Anpassung auf Dokumentebene. Zum Verwenden dieses Codes fügen Sie ihn in der ThisDocument-Klasse im Projekt ein, und rufen Sie in der ThisDocument_Startup-Methode die AddBuildingBlockControlAtSelection-Methode auf.

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;
}

Diese Version bezieht sich auf ein Add-In auf Anwendungsebene, das auf .NET Framework 4 abzielt. Zum Verwenden dieses Codes fügen Sie ihn in der ThisAddIn-Klasse im Projekt ein, und rufen Sie in der ThisAddIn_Startup-Methode die AddBuildingBlockControlAtSelection-Methode auf.

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;
}

.NET Framework-Sicherheit

Siehe auch

Referenz

ControlCollection Schnittstelle

AddBuildingBlockGalleryContentControl-Überladung

Microsoft.Office.Tools.Word-Namespace

Weitere Ressourcen

Hinzufügen von Steuerelementen zu Office-Dokumenten zur Laufzeit

Hilfsmethoden für Hoststeuerelemente

Gewusst wie: Hinzufügen von Inhaltssteuerelementen zu Word-Dokumenten