Bewerken

Delen via


Shape Interface

Definition

Represents an object in the drawing layer, such as an AutoShape, freeform, OLE object, ActiveX control, or picture.

public interface class Shape
[System.Runtime.InteropServices.Guid("000209A0-0000-0000-C000-000000000046")]
public interface Shape
type Shape = interface
Public Interface Shape
Attributes

Remarks

The Shape object is a member of the Shapes collection, which includes all the shapes in the main story of a document or in all the headers and footers of a document.

A shape is always attached to an anchoring range. You can position the shape anywhere on the page that contains the anchor.

There are three objects that represent shapes: the Shapes collection, which represents all the shapes on a document; the ShapeRange collection, which represents a specified subset of the shapes on a document (for example, a ShapeRange object could represent shapes one and four on the document, or it could represent all the selected shapes on the document); the Shape object, which represents a single shape on a document. If you want to work with several shapes at the same time or with shapes within the selection, use a ShapeRange collection.

Use Shapes(index), where index is the name or the index number, to return a single Shape object.

Each shape is assigned a default name when it is created. For example, if you add three different shapes to a document, they might be named "Rectangle 2," "TextBox 3," and "Oval 4." To give a shape a more meaningful name, set the Name property.

Use Selection.ShapeRange(index), where index is the name or the index number, to return a Shape object that represents a shape within a selection.

To add a Shape object to the collection of shapes for the specified document and return a Shape object that represents the newly created shape, use one of the following methods of the Shapes collection: AddCallout(MsoCalloutType, Single, Single, Single, Single, Object), AddCurve(Object, Object), AddLabel(MsoTextOrientation, Single, Single, Single, Single, Object), AddLine(Single, Single, Single, Single, Object), AddOLEControl(Object, Object, Object, Object, Object, Object), AddOLEObject(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object), AddPolyline(Object, Object), AddShape(Int32, Single, Single, Single, Single, Object), AddTextbox(MsoTextOrientation, Single, Single, Single, Single, Object), AddTextEffect(MsoPresetTextEffect, String, String, Single, MsoTriState, MsoTriState, Single, Single, Object), or BuildFreeform(MsoEditingType, Single, Single).

Use GroupItems(index), where index is the shape name or the index number within the group, to return a Shape object that represents a single shape in a grouped shape.

Use the Group() or Regroup() method to group a range of shapes and return a single Shape object that represents the newly formed group. After a group has been formed, you can work with the group the same way you work with any other shape.

Every Shape object is anchored to a range of text. A shape is anchored to the beginning of the first paragraph that contains the anchoring range. The shape will always remain on the same page as its anchor.

You can view the anchor itself by setting the ShowObjectAnchors property to True. The shape's Top and Left properties determine its vertical and horizontal positions. The shape's RelativeHorizontalPosition and RelativeVerticalPosition properties determine whether the position is measured from the anchoring paragraph, the column that contains the anchoring paragraph, the margin, or the edge of the page.

If the LockAnchor property for the shape is set to True, you cannot drag the anchor from its position on the page.

Use the Fill property to return the FillFormat object, which contains all the properties and methods for formatting the fill of a closed shape. The Shadow property returns the ShadowFormat object, which you use to format a shadow. Use the Line property to return the LineFormat object, which contains properties and methods for formatting lines and arrows. The TextEffect property returns the TextEffectFormat object, which you use to format WordArt. The Callout property returns the CalloutFormat object, which you use to format line callouts. The WrapFormat property returns the WrapFormat object, which you use to define how text wraps around shapes. The ThreeD property returns the ThreeDFormat object, which you use to create 3-D shapes. You can use the PickUp() and Apply() methods to transfer formatting from one shape to another.

Use the SetShapesDefaultProperties() method for a Shape object to set the formatting for the default shape for the document. New shapes inherit many of their attributes from the default shape.

Use the Type property to specify the type of shape: freeform, AutoShape, OLE object, callout, or linked picture, for instance. Use the AutoShapeType property to specify the type of AutoShape: oval, rectangle, or balloon, for instance.

Use the Width and Height properties to specify the size of the shape.

The TextFrame property returns the TextFrame object, which contains all the properties and methods for attaching text to shapes and linking the text between text frames.

Shape objects are anchored to a range of text but are free-floating and can be positioned anywhere on the page. InlineShape objects are treated like characters and are positioned as characters within a line of text. You can use the ConvertToInlineShape() method and the ConvertToShape() method to convert shapes from one type to the other. You can convert only pictures, OLE objects, and ActiveX controls to inline shapes.

Properties

Adjustments

Returns a Adjustments object that contains adjustment values for all the adjustments in the specified Shape object that represents an AutoShape or WordArt.

AlternativeText

Returns or sets the alternative text associated with a shape in a Web page.

Anchor

Returns a Range object that represents the anchoring range for the specified shape.

AnchorID
Application

Returns a Application object that represents the Microsoft Word application.

AutoShapeType

Returns or sets the shape type for the specified Shape object, which must represent an AutoShape other than a line or freeform drawing.

BackgroundStyle

Gets or sets the background style of the specified shape.

Callout

Returns a CalloutFormat object that contains callout formatting properties for the specified shape.

CanvasItems

Returns a CanvasShapes object that represents a collection of shapes in a drawing canvas.

Chart

Returns a Chart object that represents a chart within the collection of shapes in a document. Read-only.

Child

Determines if the shape is a child shape.

ConnectionSiteCount

Reserved for internal use.

Connector

Reserved for internal use.

ConnectorFormat

Reserved for internal use.

Creator

Returns a 32-bit integer that indicates the application in which the specified object was created.

Diagram

Returns a Diagram object to which a diagram node belongs.

DiagramNode

Returns a DiagramNode object that represents a node in a diagram.

EditID
Fill

Returns a FillFormat object that contains fill formatting properties for the specified shape.

Glow

Returns a GlowFormat object that represents the glow formatting for a shape. Read-only.

GroupItems

Returns a GroupShapes object that represents the individual shapes in the specified group.

HasChart

True if the specified shape has a chart. Read-only.

HasDiagram

Determines if a shape is a diagram.

HasDiagramNode

Determines if a shape is a diagram node.

HasSmartArt

Gets True if there is a SmartArt diagram present on the shape.

Height

Returns or sets the height of the specified shape in points.

HeightRelative

Returns or sets a Single that represents the percentage of the relative height of a shape. Read/write.

HorizontalFlip

Indicates that a shape has been flipped horizontally.

Hyperlink

Returns a Hyperlink object that represents the hyperlink associated with the specified shape.

ID

Returns the type for the specified object.

LayoutInCell

Returns an Integer that represents whether a shape in a table is displayed inside the table or outside of the table.

Left

Returns or sets a Single that represents the horizontal position, measured in points, of the specified shape or shape range.

LeftRelative

Returns or sets a Single that represents the relative left position of a shape. Read/write.

Line

Returns a LineFormat object that contains line formatting properties for the specified shape.

LinkFormat

Returns a LinkFormat object that represents the link options of the specified shape that's linked to a file.

LockAnchor

Determines if the specified Shape object's anchor is locked to the anchoring range.

LockAspectRatio

Determines if you can change the height and width of the shape independently of one another when you resize it or if it retains its original proportions.

Name

Returns or sets the name of the specified object.

Nodes

Returns a ShapeNodes collection that represents the geometric description of the specified shape.

OLEFormat

Returns a OLEFormat object that represents the OLE characteristics (other than linking) for the specified shape.

Parent

Returns an object that represents the parent object of the specified object.

ParentGroup

Returns a Shape object that represents the common parent shape of a child shape.

PictureFormat

Returns a PictureFormat object that contains picture formatting properties for the specified object.

Reflection

Returns a ReflectionFormat object that represents the reflection formatting for a shape. Read-only.

RelativeHorizontalPosition

Specifies to what the horizontal position of a shape is relative.

RelativeHorizontalSize

Returns or sets a WdRelativeHorizontalSize constant that represents the object to which a range of shapes is relative. Read/write.

RelativeVerticalPosition

Specifies to what the vertical position of a shape is relative.

RelativeVerticalSize

Returns or sets a WdRelativeVerticalSize constant that represents the relative vertical size of a shape. Read/write.

Rotation

Returns or sets the number of degrees the specified shape is rotated around the z-axis.

RTF

Reserved for internal use.

Script

Returns a Script object, which represents a block of script or code on the specified Web page.

Shadow

Returns a ShadowFormat object that represents the shadow formatting for the specified shape.

ShapeStyle

Gets or sets the shape style for the specified shape.

SmartArt

Gets a SmartArt object that provides a way to work with the SmartArt associated with the specified shape.

SoftEdge

Returns a SoftEdgeFormat object that represents the soft edge formatting for a shape. Read-only.

TextEffect

Returns a TextEffectFormat object that contains text-effect formatting properties for the specified shape.

TextFrame

Returns a TextFrame object that contains the text for the specified shape.

TextFrame2

Returns a TextFrame2 object that contains the text for the specified shape. Read-only.

ThreeD

Returns a ThreeDFormat object that contains formatting properties of the three-dimensional effect for the specified shape.

Title

Gets or sets a string that contains a title for the specified shape.

Top

Returns or sets the vertical position of the specified shape in points.

TopRelative

Returns or sets a Single that represents the relative top position of a shape. Read/write.

Type

Returns the shape type.

VerticalFlip

Determines if the specified shape is flipped around the vertical axis.

Vertices

Returns the coordinates of the specified freeform drawing's vertices (and control points for Bézier curves) as a series of coordinate pairs.

Visible

Determines if the specified object, or the formatting applied to it, is visible.

Width

Returns or sets the width of the specified object, in points.

WidthRelative

Returns or sets a Single that represents the relative width of a shape. Read/write.

WrapFormat

Returns a WrapFormat object that contains the properties for wrapping text around the specified shape.

ZOrderPosition

Returns the position of the specified shape in the z-order.

Methods

Activate()

Activates the specified object.

Apply()

Applies to the specified shape formatting that has been copied using the PickUp() method.

CanvasCropBottom(Single)

Crops a percentage of the height of a drawing canvas from the bottom of the canvas.

CanvasCropLeft(Single)

Crops a percentage of the width of a drawing canvas from the left side of the canvas.

CanvasCropRight(Single)

Crops a percentage of the width of a drawing canvas from the right side of the canvas.

CanvasCropTop(Single)

Crops a percentage of the height of a drawing canvas from the top of the canvas.

ConvertToFrame()

Converts the specified shape to a frame.

ConvertToInlineShape()

Converts the specified shape in the drawing layer of a document to an inline shape in the text layer.

Delete()

Deletes the specified object.

Duplicate()

Creates a duplicate of the specified Shape object, adds the new range of shapes to the Shapes collection at a standard offset from the original shapes, and then returns the new Shape object.

Flip(MsoFlipCmd)

Flips a shape horizontally or vertically.

IncrementLeft(Single)

Moves the specified shape horizontally by the specified number of points.

IncrementRotation(Single)

Changes the rotation of the specified shape around the z-axis by the specified number of degrees.

IncrementTop(Single)

Moves the specified shape vertically by the specified number of points.

PickUp()

Copies the formatting of the specified shape.

RerouteConnections()

Reserved for internal use.

ScaleHeight(Single, MsoTriState, MsoScaleFrom)

Scales the height of the shape by a specified factor.

ScaleWidth(Single, MsoTriState, MsoScaleFrom)

Scales the width of the shape by a specified factor.

Select(Object)

Selects the specified object.

SetShapesDefaultProperties()

Applies the formatting of the specified shape to a default shape for that document. New shapes inherit many of their attributes from the default shape.

Ungroup()

Ungroups any grouped shapes in the specified shape.

ZOrder(MsoZOrderCmd)

Moves the specified shape in front of or behind other shapes in the collection (that is, changes the shape's position in the z-order).

Applies to