Compartir por


Objeto Shape (Project)

Representa un objeto de un informe de Project, como un gráfico, una tabla de informe, un cuadro de texto, un dibujo de forma libre o una imagen.

Observaciones

El objeto Shape es un miembro de la colección Shapes , que incluye todas las formas del informe.

Nota:

No se implementa la grabación de macros para el objeto Shape . Es decir, al grabar una macro en Project y agregar manualmente una forma o editar elementos de forma, no se registran los pasos para agregar y manipular la forma.

Hay tres objetos que representan formas: la colección Shapes , que representa todas las formas de un documento; el objeto ShapeRange , que representa un subconjunto especificado de las formas de un documento (por ejemplo, un objeto ShapeRange podría representar formas una y cuatro en el documento, o podría representar todas las formas seleccionadas en el documento); y el objeto Shape , que representa una sola forma en un documento. Si desea trabajar con varias formas al mismo tiempo o con formas dentro de la selección, use una colección ShapeRange.

Use Shapes(Index), donde Index es el nombre de la forma o el número de índice, para devolver un único objeto Shape .

Ejemplo

En el ejemplo siguiente, la macro TestTextShape crea una forma de cuadro de texto, agrega texto y cambia el estilo de forma, el relleno, la línea, la sombra y las propiedades de reflexión. La macro FlipShape voltea la forma de arriba abajo.

Sub TestTextShape()
    Dim theReport As Report
    Dim textShape As Shape
    Dim reportName As String
    
    reportName = "Simple scalar chart"
    
    Set theReport = ActiveProject.Reports(reportName)
    Set textShape = theReport.Shapes.AddTextbox(msoTextOrientationHorizontal, 30, 30, 300, 100)
    textShape.Name = "TestTextBox"
    
    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 = 0
    
    ' Set the font for the first 15 characters to dark blue bold.
    With textShape.TextFrame2.TextRange.Characters(1, 15).Font
        .Fill.Visible = msoTrue
        .Fill.ForeColor.ObjectThemeColor = msoThemeColorAccent5
        .Fill.Transparency = 0
        .Fill.Solid
        .Size = 14
        .Bold = msoTrue
    End With
    
    textShape.ShapeStyle = msoShapeStylePreset42
    
    With textShape.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(255, 255, 0)
        .Transparency = 0
        '.Solid
    End With
   
    With textShape.Line
        .Visible = msoTrue
        .ForeColor.ObjectThemeColor = msoThemeColorText1
        .ForeColor.TintAndShade = 0
        .ForeColor.Brightness = 0
        .Transparency = 0
    End With

    textShape.Shadow.Type = msoShadow22
    textShape.Reflection.Type = msoReflectionType3
End Sub

Sub FlipShape()
    Dim theReport As Report
    Dim theShape As Shape
    Dim reportName As String
    Dim shapeName As String
    
    reportName = "Simple scalar chart"
    shapeName = "TestTextBox"
    
    Set theShape = ActiveProject.Reports(reportName).Shapes(shapeName)

    theShape.Flip msoFlipVertical
    theShape.Select
End Sub

En la figura 1 se muestra el resultado, donde la forma está seleccionada para que la pestaña FORMATO de la cinta de opciones en HERRAMIENTAS DE DIBUJO esté disponible, aunque la pestaña activa es DISEÑO en HERRAMIENTAS DE INFORME. Si no se seleccionara la forma, LAS HERRAMIENTAS DE DIBUJO y la pestaña FORMATO no estarían visibles.

Figura 1. Comprobación del modelo del objeto Shape

Comprobación del modelo del objeto Shape

Métodos

Nombre
Apply
Copy
Cut
Delete
Duplicate
Flip
IncrementLeft
IncrementRotation
IncrementTop
PickUp
RerouteConnections
ScaleHeight
ScaleWidth
Select
SetShapesDefaultProperties
Ungroup
ZOrder

Propiedades

Nombre
Adjustments
AlternativeText
Application
AutoShapeType
BackgroundStyle
BlackWhiteMode
Callout
Chart
Child
ConnectionSiteCount
Connector
ConnectorFormat
Fill
Glow
GroupItems
HasChart
HasTable
Height
HorizontalFlip
ID
Left
Line
LockAspectRatio
Name
Nodes
Parent
ParentGroup
Reflection
Rotation
Shadow
ShapeStyle
SoftEdge
Tabla
TextEffect
TextFrame
TextFrame2
ThreeD
Título
Top
Tipo
VerticalFlip
Vertices
Visible
Width
ZOrderPosition

Vea también

Objeto de gráfico de objetosde informe

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.