Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mouse position 2

Status
Not open for further replies.

Internetmanager

Technical User
Sep 9, 2005
3
FI
Hello,

How can I retreive the x,y coordinates of the current mouse position in VBA? I have a Form and I need to know the position of the mouse pointer on the form.

Please help!
 
Take a look at the MouseMove event associated with Userforms. This is defined in the Object Browser as:
Code:
Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

X & Y give the mouse coordinates.


Regards,
Mike
 
Hi
Use the MouseMove event
On a form with a default named text box, apply the following

Code:
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
TextBox1.Value = "X co-ord is " & X & " Y co-ord is " & Y
End Sub

If this isn't really what you want have a look at the MouseDown & MouseUp events.

;-)
If a man says something and there are no women there to hear him, is he still wrong? [ponder]
How do I get the best answers?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top