Nota
O acceso a esta páxina require autorización. Pode tentar iniciar sesión ou modificar os directorios.
O acceso a esta páxina require autorización. Pode tentar modificar os directorios.
Agrega un cuadro de texto al informe y devuelve un objeto Shape que representa el nuevo cuadro de texto.
Sintaxis
expresión.
AddTextbox
(Orientation,Left,Top,Width,Height)
expresión Variable que representa un objeto Shapes.
Parameters
| Nombre | Obligatorio/opcional | Tipo de datos | Descripción |
|---|---|---|---|
| Orientation | Obligatorio | MsoTextOrientation | Orientación del cuadro de texto. Es posible que algunas constantes no estén disponibles, en función del idioma instalado. |
| Left | Obligatorio | Single | Posición, en puntos, del borde izquierdo del cuadro de texto. |
| Top | Obligatorio | Single | Posición, en puntos, del borde superior del cuadro de texto. |
| Width | Obligatorio | Single | Ancho, en puntos, del cuadro de texto. |
| Height | Obligatorio | Single | Alto, en puntos, del cuadro de texto. |
| Orientación | Obligatorio | MSOTEXTORIENTATION | |
| Left | Obligatorio | FLOAT | |
| Top | Obligatorio | FLOAT | |
| Width | Obligatorio | FLOAT | |
| Height | Obligatorio | FLOAT | |
| Nombre | Obligatorio/opcional | Tipo de datos | Descripción |
Valor devuelto
Shape
Ejemplo
En el ejemplo siguiente se agrega un cuadro de texto con un fondo amarillo claro y un borde visible. La cadena de texto tiene formato y se manipula mediante miembros del objeto TextFrame2 .
Sub AddTextBoxShape()
Dim theReport As Report
Dim textShape As shape
Dim reportName As String
reportName = "Textbox report"
Set theReport = ActiveProject.Reports.Add(reportName)
Set textShape = theReport.Shapes.AddTextbox(msoTextOrientationHorizontal, 30, 50, 300, 100)
textShape.TextFrame2.TextRange.Characters.Text = "This is a test. It's only a test. " _
& "If it had been real information, there would be some real text here."
textShape.TextFrame2.TextRange.Characters(1, 15).ParagraphFormat.FirstLineIndent = 10
textShape.TextFrame2.TextRange.Characters(16).InsertBefore vbCrLf
' Set the font for the first 15 characters to dark blue bold.
With textShape.TextFrame2.TextRange.Characters(1, 15).Font
.Fill.ForeColor.ObjectThemeColor = msoThemeColorAccent5
.Fill.Solid
.Fill.Visible = msoTrue
.Size = 14
.Bold = msoTrue
End With
With textShape.Fill
.ForeColor.RGB = RGB(255, 255, 160)
.Visible = msoTrue
End With
With textShape.Line
.Weight = 1
.Visible = msoTrue
End With
End Sub
Vea también
Propiedad MsoTextOrientation (Office)
Soporte técnico y comentarios
¿Tiene preguntas o comentarios sobre VBA para Office o esta documentación? Vea Soporte técnico y comentarios sobre VBA para Office para obtener ayuda sobre las formas en las que puede recibir soporte técnico y enviar comentarios.