Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Mouse X-Y Coordinates

How can I get the x and y coordinates of where the mouse happens to be at
any particular moment on the screen?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default Mouse X-Y Coordinates

The code below will return the x- and y-coordinates in pixels as opposed to
points. Note that it is also window based instead of worksheet based. Doing
something with it is the challenge:

Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Type POINTAPI
x As Long
y As Long
End Type

Sub xxx()
Dim pos As POINTAPI
GetCursorPos pos
MsgBox pos.x & vbCr & pos.y
End Sub

I have recently posted code that determines the position of the top-left
corner of the worksheet in pixels and also converts pixels to points and
compensates (albeit not perfectly) for zoom. You need to know the position of
the top-left corner of the worksheet in pixels so that you can subtract the
correct offsets if you are to convert to points. You can thus direct the
cursor to a specified point within the worksheet. If you're interested:

http://tinyurl.com/l7uog

Regards,
Greg


"Bob" wrote:

How can I get the x and y coordinates of where the mouse happens to be at
any particular moment on the screen?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I grab graph coordinates in Excel via the mouse with VB? Chris Manning Charts and Charting in Excel 6 August 22nd 05 02:38 AM
my mouse moves diagonally when i scroll on mouse? BKMISHRA Excel Worksheet Functions 0 June 29th 05 11:43 AM
moving mouse highlights cells without touching left mouse button bremboy Excel Discussion (Misc queries) 2 January 27th 05 06:19 PM
Simple way to convert UTM ED50 coordinates to decimal coordinates? Dan[_38_] Excel Programming 8 July 11th 04 04:54 PM
Converting MouseDown Coordinates to Chart Point Coordinates Steve[_50_] Excel Programming 3 December 2nd 03 06:48 PM


All times are GMT +1. The time now is 10:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"