获取鼠标的位置坐标
分类:VBA
'API声明
Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
'自定义类型变量
Type POINTAPI
Xcoord As Long
Ycoord As Long
End Type
Sub GetCursorPosDemo()
Dim llCoord As POINTAPI
'获取鼠标位置
GetCursorPos llCoord
'显示鼠标位置坐标
MsgBox "X坐标: " & llCoord.Xcoord& vbNewLine & _
"Y坐标: " & llCoord.Ycoord
End Sub