Skip to content

Latest commit

 

History

History
59 lines (36 loc) · 1.98 KB

PowerPoint.DocumentWindow.RangeFromPoint.md

File metadata and controls

59 lines (36 loc) · 1.98 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
DocumentWindow.RangeFromPoint method (PowerPoint)
vbapp10.chm511026
vbapp10.chm511026
PowerPoint.DocumentWindow.RangeFromPoint
74bc61e5-6c6d-0510-b549-e325dd67c7a7
06/08/2017
medium

DocumentWindow.RangeFromPoint method (PowerPoint)

Returns the Shape object that is located at the point specified by the screen position coordinate pair. If no shape is located at the coordinate pair specified, then the method returns Nothing.

Syntax

expression.RangeFromPoint (x, y)

expression A variable that represents a DocumentWindow object.

Parameters

Name Required/Optional Data type Description
x Required Long The horizontal distance (in pixels) from the left edge of the screen to the point.
y Required Long The vertical distance (in pixels) from the top of the screen to the point.

Example

This example adds a new five-point star to slide one using the coordinates (288, 100). It then converts those coordinates from points to pixels, uses the RangeFromPoint method to return a reference to the new object, and changes the fill color of the star. Note that the example does not work unless you step through the code, possibly pointing to a bug with the method. The penultimate line to set a reference to the object myShape fails at runtime unless stepping through the code.

Dim myPointX As Integer, myPointY As Integer
Dim myShape As Object

ActivePresentation.Slides(1).Shapes _
    .AddShape(msoShape5pointStar, 288, 100, 100, 72).Select

myPointX = ActiveWindow.PointsToScreenPixelsX(288)
myPointY = ActiveWindow.PointsToScreenPixelsY(100)
Set myShape = ActiveWindow.RangeFromPoint(myPointX, myPointY)
myShape.Fill.ForeColor.RGB = RGB(80, 160, 130)

See also

DocumentWindow Object

[!includeSupport and feedback]