Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Get screen coordinates of cursor in MS Word

Posted on 2005-03-27
Medium Priority
Last Modified: 2008-03-17
I need to get the x,y screen pixel coordinates of the cursor (also known as Caret) in MS Word. Anyone know how?
Question by:verasen
LVL 23

Expert Comment

ID: 13642206
What exactly are you trying to do, just get the screen co ordinates on a userform from VBA or are you trying to select a word that is underneath the mouse cursor or what ?
LVL 25

Expert Comment

ID: 13642443
Apparently s/he just wants to get the Point location of the Caret (the blinky thing when you type)... I don't do VB myself.. but I'm not too sure if you can actually get the screen co-ordinates with an existing API.. What I would personally do, is get the Caret position, in the Text Box, then determine it's position (based on the font size) relative to the top-left corner of the Text Field... once you've got that, you can then add it on to the position of the Text Box (in terms of screen dimensions)..

I don't do VB as I've said, so there *might* be a really easy way.. but in one of my languages, that's how I'd probably do it.

>> IM
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 13642444
Use the GetCursorPos() API:

Private Declare Function GetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long

Private Type POINTAPI
    X As Long
    Y As Long
End Type

Private Sub Command1_Click()
    Dim Point As POINTAPI
    GetCursorPos Point
    Debug.Print Point.x & ", " & Point.y
End Sub
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 13645985
GetCursorPos tells mouse location. I need caret location (blinking thing) in MS Word

Accepted Solution

kHSw earned 750 total points
ID: 13650467
Check out the documentation about Selection.Information.

You can retrieve the horizontal and vertical position using:

LVL 23

Expert Comment

ID: 13655067
Take a look at this URL from vba express :


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Screencast - Getting to Know the Pipeline

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question