Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

ShapeRange interface

Represents a shape range, which is a set of shapes on a document.

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

public interface ShapeRange : IEnumerable

A shape range can contain as few as one shape or as many as all the shapes in the document. You can include whichever shapes you want— chosen from among all the shapes in the document or all the shapes in the selection— to construct a shape range. For example, you could construct a ShapeRange collection that contains the first three shapes in a document, all the selected shapes in a document, or all the freeform shapes in a document.

Note Most operations that you can do with a Shape object, you can also do with a ShapeRange object that contains only one shape. Some operations, when performed on a ShapeRange object that contains more than one shape, will cause an error.

Use Shapes.Range(index), where index is the name or index number of the shape or an array that contains either names or index numbers of shapes, to return a ShapeRange collection that represents a set of shapes on a document. You can programmatically use an array to construct an array of names or index numbers.

Although you can use the Range method to return any number of shapes, it's simpler to use the Item method if you want to return only a single member of the collection. For example, Shapes(1) is simpler than Shapes.Range(1).

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.

Use the Align, Distribute, or ZOrder method to position a set of shapes relative to each other or relative to the document.

Use the Group, Regroup, or Ungroup method to create and work with a single shape formed from a shape range. The GroupItems property for a Shape object returns the GroupShapes object, which represents all the shapes that were grouped to form one shape.

The recorder always uses the ShapeRange property when recording shapes.

A ShapeRange object doesn't include InlineShape objects.

© 2015 Microsoft