ControlCollection.AddBuildingBlockGalleryContentControl (Método) (Range, String)
Agrega un nuevo control BuildingBlockGalleryContentControl en el intervalo especificado del documento.
Espacio de nombres: Microsoft.Office.Tools.Word
Ensamblado: Microsoft.Office.Tools.Word (en Microsoft.Office.Tools.Word.dll)
Sintaxis
'Declaración
Function AddBuildingBlockGalleryContentControl ( _
range As Range, _
name As String _
) As BuildingBlockGalleryContentControl
BuildingBlockGalleryContentControl AddBuildingBlockGalleryContentControl(
Range range,
string name
)
Parámetros
- range
Tipo: Microsoft.Office.Interop.Word.Range
Range que proporciona los límites del nuevo control.
- name
Tipo: System.String
Nombre del nuevo control.
Valor devuelto
Tipo: Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl
El control BuildingBlockGalleryContentControl que se agregó al documento.
Excepciones
Excepción | Condición |
---|---|
ArgumentNullException | name es nullreferencia null (Nothing en Visual Basic) o tiene longitud cero. |
ControlNameAlreadyExistsException | Ya existe un control con el mismo nombre en ControlCollection. |
Comentarios
Utilice este método para agregar un nuevo control BuildingBlockGalleryContentControl en un intervalo especificado del documento en tiempo de ejecución.Para obtener más información, vea Agregar controles a documentos de Office en tiempo de ejecución.
Ejemplos
En el ejemplo de código siguiente se agrega un nuevo BuildingBlockGalleryContentControl al principio del documento.BuildingBlockGalleryContentControl muestra los bloques de creación de ecuación proporcionados por Microsoft Office Word.
Se trata de una versión para una personalización en el nivel del documento.Para usar este código, péguelo en la clase ThisDocument del proyecto y llame al método AddBuildingBlockControlAtRange desde el método ThisDocument_Startup.
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;
}
Esta versión es para un complemento de nivel de aplicación que tiene como destino .NET Framework 4 o .NET Framework 4.5.Para usar este código, péguelo en la clase ThisAddIn del proyecto y llame al método AddBuildingBlockControlAtRange desde el método ThisAddIn_Startup.
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;
}
Seguridad de .NET Framework
- Plena confianza para el llamador inmediato. Un código de confianza parcial no puede utilizar este miembro. Para obtener más información, vea Utilizar bibliotecas de código que no es de plena confianza.
Vea también
Referencia
AddBuildingBlockGalleryContentControl (Sobrecarga)
Microsoft.Office.Tools.Word (Espacio de nombres)
Otros recursos
Agregar controles a documentos de Office en tiempo de ejecución