BuildingBlockGalleryContentControl.BuildingBlockType 屬性
取得或設定在 BuildingBlockGalleryContentControl 中顯示的建置組塊型別。
命名空間: Microsoft.Office.Tools.Word
組件: Microsoft.Office.Tools.Word (在 Microsoft.Office.Tools.Word.dll 中)
語法
'宣告
Property BuildingBlockType As WdBuildingBlockTypes
WdBuildingBlockTypes BuildingBlockType { get; set; }
屬性值
型別:Microsoft.Office.Interop.Word.WdBuildingBlockTypes
其中一個 Microsoft.Office.Interop.Word.WdBuildingBlockTypes 值。
例外狀況
例外狀況 | 條件 |
---|---|
COMException | 屬性設定為 Microsoft.Office.Interop.Word.WdBuildingBlockTypes 值,這個值會識別無法在 BuildingBlockGalleryContentControl 中顯示的建置組塊分類。 |
備註
所有建置組塊都屬於某個陳列庫和分類。 使用 BuildingBlockGalleryContentControl 屬性,指定在 BuildingBlockType 中所顯示的建置組塊庫。
BuildingBlockGalleryContentControl 只能顯示某些建置組塊庫。 BuildingBlockType 屬性只能設定為下列 Microsoft.Office.Interop.Word.WdBuildingBlockTypes 值:
wdTypeAutoText
wdTypeCustom1
wdTypeCustom2
wdTypeCustom3
wdTypeCustom4
wdTypeCustom5
wdTypeCustomAutoText
wdTypeCustomEquations
wdTypeCustomQuickParts
wdTypeCustomTables
wdTypeEquations
wdTypeQuickParts
wdTypeTables
若要指定由 BuildingBlockGalleryContentControl 所顯示的建置組塊分類,請使用 BuildingBlockCategory 屬性。
範例
下列程式碼範例會將新的 BuildingBlockGalleryContentControl 加入至文件的開頭。 BuildingBlockGalleryContentControl 會顯示 Microsoft Office Word 所提供的方程式建置組塊 (Building Block)。 這個範例會將 BuildingBlockType 屬性設定為 wdTypeEquations。
這是示範文件層級自訂的版本。 若要使用這段程式碼,請將它貼到專案的 ThisDocument 類別中,並從 ThisDocument_Startup 方法呼叫 AddBuildingBlockControlAtSelection 方法。
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;
}
這是示範應用程式層級增益集的版本。 若要使用這段程式碼,請將它貼到專案的 ThisAddIn 類別中,並從 ThisAddIn_Startup 方法呼叫 AddBuildingBlockControlAtSelection 方法。
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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。