Shape Interface

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.

Namespace:  Microsoft.Office.Interop.Excel
Assembly:  Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)

Syntax

'Declaration
<InterfaceTypeAttribute()> _
<GuidAttribute("00024439-0000-0000-C000-000000000046")> _
Public Interface Shape
'Usage
Dim instance As Shape
[InterfaceTypeAttribute()]
[GuidAttribute("00024439-0000-0000-C000-000000000046")]
public interface Shape

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 and AddNodes 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.

See Also

Reference

Shape Members

Microsoft.Office.Interop.Excel Namespace