Właściwość BuildingBlockGalleryContentControl.BuildingBlockType —
Pobiera lub ustawia typ bloki konstrukcyjne, które są wyświetlane w BuildingBlockGalleryContentControl.
Przestrzeń nazw: Microsoft.Office.Tools.Word
Zestaw: Microsoft.Office.Tools.Word (w Microsoft.Office.Tools.Word.dll)
Składnia
'Deklaracja
Property BuildingBlockType As WdBuildingBlockTypes
WdBuildingBlockTypes BuildingBlockType { get; set; }
Wartość właściwości
Typ: Microsoft.Office.Interop.Word.WdBuildingBlockTypes
Jednym z Microsoft.Office.Interop.Word.WdBuildingBlockTypes wartości.
Wyjątki
Wyjątek | Warunek |
---|---|
COMException | Właociwooć jest ustawiona na Microsoft.Office.Interop.Word.WdBuildingBlockTypes wartość, która określa kategorię bloki konstrukcyjne, które nie mogą być wyświetlane w BuildingBlockGalleryContentControl. |
Uwagi
Wszystkie bloki konstrukcyjne należą do galerię i kategorię.Użycie BuildingBlockType właściwość, aby określić które galerii bloków konstrukcyjnych do wyświetlenia w BuildingBlockGalleryContentControl.
A BuildingBlockGalleryContentControl można wyświetlić tylko niektórych galeriach bloków konstrukcyjnych.BuildingBlockType Właściwość można ustawić tylko do następujących Microsoft.Office.Interop.Word.WdBuildingBlockTypes wartości:
wdTypeAutoText
wdTypeCustom1
wdTypeCustom2
wdTypeCustom3
wdTypeCustom4
wdTypeCustom5
wdTypeCustomAutoText
wdTypeCustomEquations
wdTypeCustomQuickParts
wdTypeCustomTables
wdTypeEquations
wdTypeQuickParts
wdTypeTables
Określenie kategorii bloki konstrukcyjne, które są wyświetlane przez BuildingBlockGalleryContentControl, użyj BuildingBlockCategory właściwość.
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.W przykładzie ustawiana BuildingBlockType właściwość, aby wdTypeEquations.
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.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
- 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 Przy użyciu bibliotek z częściowo zaufanego kodu..