Selection Object (PowerPoint)

Office 2013 and later

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

Represents the selection in the specified document window. The Selection object is deleted whenever you change slides in an active slide view (the Type property will return ppSelectionNone).

Use the Selection property to return the Selection object. The following example places a copy of the selection in the active window on the Clipboard.


Use the ShapeRange , SlideRange , or TextRange property to return a range of shapes, slides, or text from the selection.

The following example sets the fill foreground color for the selected shapes in window two, assuming that there's at least one shape selected, and assuming that all selected shapes have a fill whose forecolor can be set.

With Windows(2).Selection.ShapeRange.Fill

    .Visible = True

    .ForeColor.RGB = RGB(255, 0, 255)

End With

The following example sets the text in the first selected shape in window two if that shape contains a text frame.

With Windows(2).Selection.ShapeRange(1)

    If .HasTextFrame Then

        .TextFrame.TextRange = "Current Choice"

    End If

End With

The following example cuts the selected text in the active window and places it on the Clipboard.


The following example duplicates all the slides in the selection (if you're in slide view, this duplicates the current slide).


If you don't have an object of the appropriate type selected when you use one of these properties (for instance, if you use the ShapeRange property when there are no shapes selected), an error occurs. Use the Type property to determine what kind of object or objects are selected. The following example checks to see whether the selection contains slides. If the selection does contain slides, the example sets the background for the first slide in the selection.

With Windows(2).Selection

    If .Type = ppSelectionSlides Then

        With .SlideRange(1)

            .FollowMasterBackground = False

            .Background.Fill.PresetGradient _

                msoGradientHorizontal, 1, msoGradientLateSunset

        End With

    End If

End With
© 2016 Microsoft