
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long
'Private Declare Function ScreenToClient Lib "user32" ( _
'ByVal hwnd As Long, _
lpPoint As POINTAPI) As Long
Dim pos As POINTAPI
Sub macro_activesheet()
GetCursorPos pos
'ScreenToClient Me.hwnd, pos
Range("Q5").Value = pos.X
Range("R5").Value = pos.Y
End Sub |
'esempio 1
activesheet.Shapes.AddLine((Range("Q11").Value), (Range("R11").Value), (Range("Q12").Value), (Range("R12").Value)).Select
'esempio 2
Range("Q11").Value = (pos.x - 26) * 0.75
Range("R11").Value = (pos.y - 114) * 0.75
'pos.x e pos.y sono le coordinate del cursore rispetto al monitor. |
