편집

다음을 통해 공유


Shape Interface

Definition

Represents an object in the drawing layer, such as an AutoShape, freeform, OLE object, or picture. The Shape object is a member of the Shapes collection. The Shapes collection contains all the shapes on a slide.

public interface class Shape
[System.Runtime.InteropServices.Guid("00024439-0000-0000-C000-000000000046")]
[System.Runtime.InteropServices.InterfaceType(2)]
public interface Shape
Public Interface Shape
Attributes

Remarks

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); and 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.

This section describes how to:

  • Return an existing shape.
  • Return a shape within the selection.
  • Return the shapes attached to the ends of a connector.
  • Return a newly created freeform.
  • Return a single shape from within a group.
  • Return a newly formed group of shapes.

Returning an Existing Shape

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

Each shape is assigned a default name when you add it to the Shapes collection. To give the shape a more meaningful name, use the Name property.

Returning a Shape Within the Selection

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

Returning the Shapes Attached to the Ends of a Connector

To return a Shape object that represents one of the shapes attached by a connector, use the BeginConnectedShape or EndConnectedShape property.

Returning a newly created freeform

Use the BuildFreeform(MsoEditingType, Single, Single) and AddNodes(MsoSegmentType, MsoEditingType, Single, Single, Object, Object, Object, Object) methods to define the geometry of a new freeform, and use the ConvertToShape() method to create the freeform and return the Shape object that represents it.

Returning a Single Shape from Within a Group

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.

Returning a Newly Formed Group of Shapes

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.

Properties

Adjustments

Returns an Adjustments object that contains adjustment values for all the adjustments in the specified shape. Read-only.

AlternativeText

Returns or sets the descriptive (alternative) text string for a Shape object when the object is saved to a Web page. Read/write String.

Application

Returns an Application object that represents the Microsoft Excel application. Read-only.

AutoShapeType

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

BackgroundStyle

Returns or sets the background style. Read/write.

BlackWhiteMode

Returns or sets a value that indicates how the specified shape appears when the presentation is viewed in black-and-white mode. Read/write MsoBlackWhiteMode.

BottomRightCell

Returns a Range object that represents the cell that lies under the lower-right corner of the object. Read-only.

Callout

Returns a CalloutFormat object that contains callout formatting properties for the specified shape. Applies to Shape objects that represent line callouts. Read-only.

CanvasItems

Reserved for internal use.

Chart

Returns an object that represents the _Chart contained in the Shape. Read-only.

Child

Returns msoTrue if the specified shape is a child shape or if all shapes in a shape range are child shapes of the same parent. Read-only MsoTriState.

ConnectionSiteCount

Returns the number of connection sites on the specified shape. Read-only Integer.

Connector

True if the specified shape is a connector. Read-only MsoTriState.

ConnectorFormat

Returns a ConnectorFormat object that contains connector formatting properties. Applies to Shape objects that represent connectors. Read-only.

ControlFormat

Returns a ControlFormat object that contains Microsoft Excel control properties. Read-only.

Creator

Returns a 32-bit integer that indicates the application in which this object was created. If the object was created in Microsoft Excel, this property returns the string XCEL, which is equivalent to the hexadecimal number 5843454C. Read-only XlCreator.

Diagram

Returns a Diagram object representing a diagram.

DiagramNode

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

DrawingObject

Reserved for internal use.

Fill

Returns a FillFormat object that contains fill formatting properties for the specified chart or shape. Read-only.

FormControlType

Returns the Microsoft Excel control type. Read-only XlFormControl.

Glow

Returns an object for a specified shape that contains glow formatting properties for that shape. Read-only.

GroupItems

Returns a GroupShapes object that represents the individual shapes in the specified group. Use the Item(Object) method of the GroupShapes object to return a single shape from the group. Applies to Shape objects that represent grouped shapes. Read-only.

HasChart

Returns information on if a Shape contains a chart. Read-only.

HasDiagram

Returns whether a shape or shape range contains a diagram. Read-only MsoTriState.

HasDiagramNode

Returns a value indicating whether a diagram node exists in a given shape or shape range. Read-only MsoTriState.

HasSmartArt

Gets whether there is a SmartArt diagram present on the specified shape.

Height

The height of the object. Read/write Single.

HorizontalFlip

True if the specified shape is flipped around the horizontal axis. Read-only MsoTriState.

Hyperlink

Returns a Hyperlink object that represents the hyperlink for the shape.

ID

Returns the type for the specified object. Read-only Integer.

Left

The distance from the left edge of the object to the left edge of column A (on a worksheet) or the left edge of the chart area (on a chart). Read/write Single.

Line

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

LinkFormat

Returns a LinkFormat object that contains linked OLE object properties. Read-only.

LockAspectRatio

True if the specified shape retains its original proportions when you resize it. False if you can change the height and width of the shape independently of one another when you resize it. Read/write MsoTriState.

Locked

True if the object is locked, False if the object can be modified when the sheet is protected. Read/write Boolean.

Name

Returns or sets the name of the object. Read/write String.

Nodes

Returns a ShapeNodes collection that represents the geometric description of the specified shape. Applies to Shape objects that represent freeform drawings.

OLEFormat

Returns an OLEFormat object that contains OLE object properties. Read-only.

OnAction

Returns or sets the name of a macro that’s run when the specified object is clicked. Read/write String.

Parent

Returns the parent object for the specified object. Read-only.

ParentGroup

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

PictureFormat

Returns a PictureFormat object that contains picture formatting properties for the specified shape. Applies to Shape objects that represent pictures or OLE objects. Read-only.

Placement

Returns or sets the way the object is attached to the cells below it. Read/write XlPlacement.

Reflection

Returns an object that contains reflection formatting properties for the shape. Read-only.

Rotation

Returns or sets the rotation of the shape in degrees. Read/write Single.

Script

Returns the Script object, which represents a block of script or code on the specified Web page. If the page contains no script, nothing is returned.

Shadow

True if the object has a shadow. Read/write Boolean.

ShapeStyle

Returns or sets a MsoShapeStyleIndex that represents the shape style of the shape. Read/write.

SmartArt

Gets an object that represents the SmartArt associated with the shape.

SoftEdge

Returns a SoftEdgeFormat object for a specified shape that contains soft edge formatting properties for the shape. Read-only.

TextEffect

Returns a TextEffectFormat object that contains text-effect formatting properties for the specified shape. Applies to T:Microsoft.Office.Interop.Excel.Shape objects that represent WordArt. Read-only.

TextFrame

Returns a TextFrame object that contains the alignment and anchoring properties for the specified shape. Read-only.

TextFrame2

Returns an object that contains text formatting for the specified shape. Read-only.

ThreeD

Returns a ThreeDFormat object that contains 3-D – effect formatting properties for the specified shape. Read-only.

Title

Gets or sets the title of the alternative text associated with the specified shape.

Top

The distance from the top edge of the topmost shape in the shape range to the top edge of the worksheet. Read/write Single.

TopLeftCell

Returns a Range object that represents the cell that lies under the upper-left corner of the specified object. Read-only.

Type

Returns or sets the shape type. Read-only MsoShapeType.

VerticalFlip

True if the specified shape is flipped around the vertical axis. Read-only MsoTriState.

Vertices

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

Visible

Determines whether the object is visible. Read/write MsoTriState.

Width

The width of the object. Read/write Single.

ZOrderPosition

Returns the position of the specified shape in the z-order. Read-only Integer.

Methods

Apply()

Applies to the specified shape formatting that’s been copied by using the PickUp() method.

CanvasCropBottom(Single)

Reserved for internal use.

CanvasCropLeft(Single)

Reserved for internal use.

CanvasCropRight(Single)

Reserved for internal use.

CanvasCropTop(Single)

Reserved for internal use.

Copy()

Copies the object to the Clipboard.

CopyPicture(Object, Object)

Copies the selected object to the Clipboard as a picture.

Cut()

Cuts the object to the Clipboard or pastes it into a specified destination.

Delete()

Deletes the object.

Duplicate()

Duplicates the object and returns a reference to the new copy.

Flip(MsoFlipCmd)

Flips the specified shape around its horizontal or vertical axis.

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. Use the Rotation property to set the absolute rotation of the shape.

IncrementTop(Single)

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

PickUp()

Copies the formatting of the specified shape. Use the Apply() method to apply the copied formatting to another shape.

RerouteConnections()

Reroutes connectors so that they take the shortest possible path between the shapes they connect.

ScaleHeight(Single, MsoTriState, Object)

Scales the height of the shape by a specified factor.

ScaleWidth(Single, MsoTriState, Object)

Scales the width of the shape by a specified factor.

Select(Object)

Selects the object.

SetShapesDefaultProperties()

Makes the formatting of the specified shape the default formatting for the shape.

Ungroup()

Ungroups any grouped shapes in the specified shape or range of shapes. Disassembles pictures and OLE objects within the specified shape. Returns the ungrouped shapes as a single ShapeRange object.

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