返回位于屏幕上指定坐标位置的
Shape
或
Range 对象。如果指定坐标位置上没有任何形状,则此方法将返回
Nothing。
语法
表达式.RangeFromPoint(x, y)
表达式 一个代表 Window 对象的变量。
参数
名称 | 必选/可选 | 数据类型 | 说明 |
---|
x | 必选 | Long | 表示从顶部开始到屏幕左边缘的水平距离的值(以像素为单位)。 |
y | 必选 | Long | 表示从左侧开始到屏幕顶部的垂直距离的值(以像素为单位)。 |
返回值
Object
示例
如果形状为图表、线条或图片,则本示例立即在鼠标指针下方返回该形状的可选文字。
示例代码 |
---|
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
|