ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Mouse pointer position, excel2002 (https://www.excelbanter.com/excel-programming/329905-mouse-pointer-position-excel2002.html)

tc

Mouse pointer position, excel2002
 
I give up. How do I retrieve the x-y coordinates of the HotSpot within the
active window? I've been struggling with this forever.

Tony Rizzo



[email protected]

Mouse pointer position, excel2002
 
'Put this bit at the top of your code window:

Declare Function GetUserName Lib "ADVAPI32.DLL" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
'adapted from a sub by Vasant
'used by Module_PopUp sub to get the mouse coordinates when a cell is
clicked
Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As
Long
Type POINTAPI
X As Long
Y As Long
End Type

'used by Module_PopUp sub to get the mouse coordinates when a cell is
clicked
Function ShowPos() As Variant
Dim lRetVal As Long
Dim Pos As POINTAPI
Dim TempArray(1 To 2) As Long
lRetVal = GetCursorPos(Pos)
TempArray(1) = Pos.X
TempArray(2) = Pos.Y
ShowPos = TempArray
End Function

regards
Paul



All times are GMT +1. The time now is 03:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com