![]() |
#1
|
|||
|
|||
![]()
Greetings,
Is it possible to get the distance between a selected word and the left margin by VBA word. I searched through a few websites and got hands on some macros which will give the celladress in excel . Could it be modified to get the distance in msword? Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Create custom variable that holds two integers Type POINTAPI Xcoord As Long Ycoord As Long End Type Sub GetCursorPosDemoO() Dim llCoord As POINTAPI Dim rng As Range ' Get the cursor positions GetCursorPos llCoord ' Display the cursor position coordinates 'MsgBox "X Position: " & llCoord.Xcoord & vbNewLine & "Y Position: " & llCoord.Ycoord Set rng = GetRange(llCoord.Xcoord, llCoord.Ycoord) If Not rng Is Nothing Then MsgBox "Cell under mouse is :" & rng.Address Else MsgBox "Not a valid location." End If End Sub Function GetRange(x As Long, y As Long) As Range Set GetRange = ActiveWindow.RangeFromPoint(x, y) End Function |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Enter x, y coordinates and displays a number | arthurz11 | Excel | 8 | 05-21-2019 02:26 PM |
adding X Y coordinates from 3D Map to source data | NOLA | Excel | 0 | 04-11-2017 11:10 AM |
Parse coordinates in Word | stephanberger4 | Word | 3 | 08-21-2016 02:05 PM |
![]() |
Deltaj | Word VBA | 2 | 12-04-2014 02:13 PM |
![]() |
MaxInCO | Word VBA | 5 | 12-11-2013 03:28 PM |