Sort/Order related procedures in class Shape (PowerPoint VBA)

This page presents procedures from class Shape related to the theme Sort/Order: ZOrder, ZOrderPosition, ShapeRange.ZOrder and ShapeRange.ZOrderPosition

ZOrder

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

The ZOrderCmd parameter value can be one of these MsoZOrderCmd constants.

Syntax : expression.ZOrder (ZOrderCmd)

ZOrderCmd: Specifies where to move the specified shape relative to the other shapes.

ActivePresentation.Slides(1).Shapes(1).ZOrder ZOrderCmd:=msoBringToFront

ZOrderPosition

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

Shapes(1) returns the shape at the back of the z-order, and Shapes(Shapes.Count) returns the shape at the front of the z-order. To set the shape's position in the z-order, use the ZOrder method. A shape's position in the z-order corresponds to the shape's index number in the Shapes collection. For example, if there are four shapes on the slide, the expression myDocument.Shapes(1) returns the shape at the back of the z-order, and the expression myDocument.Shapes(4) returns the shape at the front of the z-order. Whenever you add a new shape to a collection, it is added to the front of the z-order by default.

Dim lngZOrderPosition As Long
lngZOrderPosition = ActivePresentation.Slides(1).Shapes(1).ZOrderPosition

ShapeRange.ZOrder

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

The ZOrderCmd parameter value can be one of these MsoZOrderCmd constants.

Syntax : expression.ZOrder (ZOrderCmd)

ZOrderCmd: Specifies where to move the specified shape range relative to the other shapes.

ActiveWindow.RangeFromPoint.Ungroup.ZOrder ZOrderCmd:=msoBringToFront

ShapeRange.ZOrderPosition

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

Shapes(1) returns the shape at the back of the z-order, and Shapes(Shapes.Count) returns the shape at the front of the z-order. To set the shape's position in the z-order, use the ZOrder method. A shape's position in the z-order corresponds to the shape's index number in the Shapes collection. For example, if there are four shapes on the slide, the expression myDocument.Shapes(1) returns the shape at the back of the z-order, and the expression myDocument.Shapes(4) returns the shape at the front of the z-order. Whenever you add a new shape to a collection, it is added to the front of the z-order by default.

Dim lngZOrderPosition As Long
lngZOrderPosition = ActivePresentation.Slides(1).Shapes(1).Ungroup.ZOrderPosition