Table of contents
TOC
Collapse the table of content
Expand the table of content

ShapeRange Object (PowerPoint)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

Represents a shape range, which is a set of shapes on a document. A shape range can contain as few as a single shape or as many as all the shapes on the document.

Remarks

You can include whichever shapes you want — chosen from among all the shapes on 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 on a document, all the selected shapes on a document, or all the freeforms on a document.

For an overview of how to work with either a single shape or with more than one shape at a time, see How to: Work with Shapes (Drawing Objects).

The following examples describe how to:

  • Return a set of shapes you specify by name or index number.

  • Return all or some of the selected shapes on a document.

Example

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 use the Array function to construct an array of names or index numbers. The following example sets the fill pattern for shapes one and three on myDocument.

Set myDocument = ActivePresentation.Slides(1)

myDocument.Shapes.Range(Array(1, 3)).Fill _

    .Patterned msoPatternHorizontalBrick

The following example sets the fill pattern for the shapes named "Oval 4" and "Rectangle 5" on myDocument.

Set myDocument = ActivePresentation.Slides(1)

Set myRange = myDocument.Shapes _

    .Range(Array("Oval 4", "Rectangle 5"))

myRange.Fill.Patterned msoPatternHorizontalBrick

Although you can use the Rangemethod to return any number of shapes or slides, it is simpler to use the Itemmethod if you want to return only a single member of the collection. For example, Shapes(1) is simpler than Shapes.Range(1).

Use the ShapeRangeproperty of the Selection object to return all the shapes in the selection. The following example sets the fill foreground color for all the shapes in the selection in window one, assuming that there's at least one shape in the selection.

Windows(1).Selection.ShapeRange.Fill.ForeColor _

    .RGB = RGB(255, 0, 255)

Use Selection.ShapeRange (index), where index is the shape name or the index number, to return a single shape within the selection. The following example sets the fill foreground color for shape two in the collection of selected shapes in window one, assuming that there are at least two shapes in the selection.

Windows(1).Selection.ShapeRange(2).Fill.ForeColor _

    .RGB = RGB(255, 0, 255)

Methods

Name
Align
Apply
ApplyAnimation
ConvertTextToSmartArt
Copy
Cut
Delete
Distribute
Duplicate
Flip
Group
IncrementLeft
IncrementRotation
IncrementTop
Item
MergeShapes
PickUp
PickupAnimation
Regroup
RerouteConnections
ScaleHeight
ScaleWidth
Select
SetShapesDefaultProperties
Ungroup
UpgradeMedia
ZOrder

Properties

Name
ActionSettings
Adjustments
AlternativeText
AnimationSettings
Application
AutoShapeType
BackgroundStyle
BlackWhiteMode
Callout
Chart
Child
ConnectionSiteCount
Connector
ConnectorFormat
Count
Creator
CustomerData
Fill
Glow
GroupItems
HasChart
HasInkXML
HasSmartArt
HasTable
HasTextFrame
Height
HorizontalFlip
Id
InkXML
IsNarration
Left
Line
LinkFormat
LockAspectRatio
MediaFormat
MediaType
Name
Nodes
OLEFormat
Parent
ParentGroup
PictureFormat
PlaceholderFormat
Reflection
Rotation
Shadow
ShapeStyle
SmartArt
SoftEdge
Table
Tags
TextEffect
TextFrame
TextFrame2
ThreeD
Title
Top
Type
VerticalFlip
Vertices
Visible
Width
ZOrderPosition

See also

Other resources

PowerPoint Object Model Reference

© 2017 Microsoft