RangeFromPoint Method Example

This example returns the alternative text for the shape immediately below the mouse pointer if the shape is a chart, line, or picture.

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