Window.RangeFromPoint procedure builder

Window.RangeFromPoint (Word)

Returns the Range or Shape range that is located at the point specified by the screen position coordinate pair.

If no range or shape is located at the coordinate pair specified, the method returns Nothing.

RangeFromPoint (x, y)

Dim pLeft As Long 
Dim pTop As Long 
Dim pWidth As Long 
Dim pHeight As Long 
Dim newShape As Object 
Dim newDoc As New Document 
 
With newDoc 
 .Shapes.AddShape msoShape5pointStar, _ 
 288, 100, 100, 72 
 .ActiveWindow.GetPoint pLeft, pTop, _ 
 pWidth, pHeight, .Shapes(1) 
 Set newShape = .ActiveWindow.RangeFromPoint(pLeft _ 
 + pWidth * 0.5, pTop + pHeight * 0.5) 
 newShape.Fill.ForeColor.RGB = RGB(80, 160, 130) 
End With

Arguments

The following arguments are required:

x (Long) - The horizontal distance (in pixels) from the left edge of the screen to the point.

y (Long) - The vertical distance (in pixels) from the top of the screen to the point.