![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 3
|
Is there anyway to know what the current position the cursor is?
|
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 2,908
|
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Hi
I don't know which context you are looking for... This is a windows screen cursor position. Position 0 will be at the upper left hand corner of the screen, not the worksheet.. Ex NOT Cell A1 The only way I know how to capture the cursor location in the actual app would be to use an image box and capture the coordinates via the image's mouse move event. Tom Option Explicit Type POINTAPI x As Long y As Long End Type Private Declare Function GetCursorPos Lib "user32" _ (lpPoint As POINTAPI) As Long Dim z As POINTAPI ' Declare variable Sub GetCursor() Range("A1") = "X = " Range("A2") = "Y = " Do GetCursorPos z Range("B1") = "x: " & z.x ' Get x co-ordinets Range("B2") = "y: " & z.y ' Get y co-ordinets DoEvents Loop End Sub |
|
|
|
|
|
#4 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
Replace the Do with this; MsgBox "To stop the prgm just select A1", vbSystemModal Do Until ActiveCell.Address = "$A$1" This will give you the readings...then when you want the prgm to Stop just place your cursor @ A1. |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|