Metoda ControlCollection.AddBuildingBlockGalleryContentControl — (Range, String)
Dodaje nowy BuildingBlockGalleryContentControl w zakresie określonym w dokumencie.
Przestrzeń nazw: Microsoft.Office.Tools.Word
Zestaw: Microsoft.Office.Tools.Word (w Microsoft.Office.Tools.Word.dll)
Składnia
'Deklaracja
Function AddBuildingBlockGalleryContentControl ( _
range As Range, _
name As String _
) As BuildingBlockGalleryContentControl
BuildingBlockGalleryContentControl AddBuildingBlockGalleryContentControl(
Range range,
string name
)
Parametry
- range
Typ: Microsoft.Office.Interop.Word.Range
A Range udostępniający granice dla nowego formantu.
- name
Typ: System.String
Nazwa nowego formantu.
Wartość zwracana
Typ: Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl
BuildingBlockGalleryContentControl Do dokumentu dodano.
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ż w ControlCollection. |
Uwagi
Ta metoda służy do dodawania nowego BuildingBlockGalleryContentControl w pewnym zakresie 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 kod dodaje nowy BuildingBlockGalleryContentControl do początku dokumentu.BuildingBlockGalleryContentControl Wyświetla równanie bloków konstrukcyjnych, które są dostarczane przez program Microsoft Office Word.
Ta wersja jest dla dostosowania poziomu dokumentu.Aby użyć tego kodu, wklej go do ThisDocument klasy w projekcie i wywołanie AddBuildingBlockControlAtRange metodę z ThisDocument_Startup metody.
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;
}
Ta wersja jest na poziomie aplikacji dodatek jest przeznaczony dla .NET Framework 4 lub .NET Framework 4.5.Aby użyć tego kodu, wklej go do ThisAddIn klasy w projekcie i wywołanie AddBuildingBlockControlAtRange metodę z ThisAddIn_Startup metody.
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;
}
Zabezpieczenia programu .NET Framework
- Pełne zaufanie do bezpośredniego wywołującego. Tego elementu członkowskiego nie można używać w kodzie częściowo zaufanym. Aby uzyskać więcej informacji, zobacz Używanie bibliotek pochodzących z częściowo zaufanego kodu.
Zobacz też
Informacje
Przeciążenie AddBuildingBlockGalleryContentControl
Przestrzeń nazw Microsoft.Office.Tools.Word
Inne zasoby
Dodawanie formantów do dokumentów pakietu Office w czasie wykonywania
Porady: dodawanie formantów zawartości do dokumentów programu Word