Get screen coordinates of cursor in MS Word

I need to get the x,y screen pixel coordinates of the cursor (also known as Caret) in MS Word. Anyone know how?
verasenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shane Russell2nd Line Desktop SupportCommented:
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 ?
0
InteractiveMindCommented:
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
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
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
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

verasenAuthor Commented:
GetCursorPos tells mouse location. I need caret location (blinking thing) in MS Word
0
kHSwCommented:
Check out the documentation about Selection.Information.

You can retrieve the horizontal and vertical position using:
Selection.Information(wdHorizontalPositionRelativeToPage)
Selection.Information(wdVerticalPositionRelativeToPage)

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Shane Russell2nd Line Desktop SupportCommented:
Take a look at this URL from vba express :

http://www.vbaexpress.com/forum/showthread.php?t=327
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.