I have drawn an irregular rectangle shape using “Lines” in Excel 2000. I have assigned a macro titled “WhereAmI” (see below) to that shape that outputs the x and y position of the cursor. And it works just fine. But, I need to set x = 0 and y = 0 at the lower left corner of this irregular rectangle shape and reference (or offset) the cursor position from that lower left corner position. This shape is not in a userform, it’s just placed on top of a worksheet.
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Sub WhereAmI()
Dim pTargetPoint As POINTAPI
Dim lRetVal As Long
lRetVal = GetCursorPos(pTargetPoint)
MsgBox "My Position:" & vbLf & pTargetPoint.x & "," & pTargetPoint.y
End Sub
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Sub WhereAmI()
Dim pTargetPoint As POINTAPI
Dim lRetVal As Long
lRetVal = GetCursorPos(pTargetPoint)
MsgBox "My Position:" & vbLf & pTargetPoint.x & "," & pTargetPoint.y
End Sub