Udostępnij za pośrednictwem


Metoda ControlCollection.AddBuildingBlockGalleryContentControl — (String)

Dodano nowy BuildingBlockGalleryContentControl w bieżącego zaznaczenia w dokumencie.

Przestrzeń nazw:  Microsoft.Office.Tools.Word
Zestaw:  Microsoft.Office.Tools.Word (w Microsoft.Office.Tools.Word.dll)

Składnia

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

Parametry

Wartość zwracana

Typ: Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl
BuildingBlockGalleryContentControl Który został dodany do dokumentu.

Wyjątki

Wyjątek Warunek
ArgumentNullException

namejest nullodwołanie o wartości null (Nothing w języku Visual Basic) lub ma zerową długość.

ControlNameAlreadyExistsException

Formant o tej samej nazwie jest już pod ControlCollection.

Uwagi

Metoda ta pozwala dodać nowy BuildingBlockGalleryContentControl w bieżącego zaznaczenia w dokumencie w czasie wykonywania.Aby uzyskać więcej informacji, zobacz Dodawanie formantów do dokumentów pakietu Office w czasie wykonywania.

Przykłady

Poniższy przykład kodu dodaje nowy BuildingBlockGalleryContentControl do początku dokumentu.BuildingBlockGalleryContentControl Wyświetla równanie bloki konstrukcyjne, które zostały udostępnione przez program Microsoft Office Word.

Ta wersja jest dostosowywanie poziomie dokumentu.Aby użyć tego kodu, wklej go do ThisDocument klasy w projekcie, a wywołanie AddBuildingBlockControlAtSelection metodę z ThisDocument_Startup metoda.

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

Ta wersja jest na poziomie aplikacji dodatek programu rozprzestrzeniającym się .NET Framework 4 lub .NET Framework 4.5.Aby użyć tego kodu, wklej go do ThisAddIn klasy w projekcie, a wywołanie AddBuildingBlockControlAtSelection metodę z ThisAddIn_Startup metoda.

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

Zabezpieczenia programu .NET Framework

Zobacz też

Informacje

ControlCollection Interfejs

Przeciążenie AddBuildingBlockGalleryContentControl

Przestrzeń nazw Microsoft.Office.Tools.Word

Inne zasoby

Dodawanie formantów do dokumentów pakietu Office w czasie wykonywania

Jak: dodawanie formantów zawartości do dokumentów programu Word