返回位于屏幕上指定坐标位置的 Shape 或 Range 对象。如果指定坐标位置上没有任何图形,则此方法将返回 Nothing。
expression.RangeFromPoint(x, y)
expression 该表达式返回一个 Window 对象。
x Long 类型,必需。此值(单位:像素)代表从顶部开始到屏幕左边缘的横向距离。
y Long 类型,必选。此值(单位:像素)代表从左部开始到屏幕顶部的纵向距离。
如果图形为图表、线条或图片,则本示例立即在鼠标指针下方返回该图形的可选文字。
Private Function AltText(ByVal intMouseX As Integer, _
        ByVal intMouseY as Integer) As String
    Set objShape = ActiveWindow.RangeFromPoint _
        (x:=intMouseX, y:=intMouseY)
    If Not objShape Is Nothing Then
        With objShape
            Select Case .Type
                Case msoChart, msoLine, msoPicture:
                    AltText = .AlternativeText
                Case Else:
                    AltText = ""
            End Select
        End With
    Else
        AltText = ""
    End If
End Function