|
Answer» I am LOOKING for help with a MS WORD VBA code that will run in a macro to find the x and y COORDINATES of selected range of TEXT.
xposition = Selection.Information(wdHorizontalPositionRelativeToPage) yposition = Selection.Information(wdVerticalPositionRelativeToPage)
The above code provides the X and Y of the START of the selection (or where the curser is).
How do I find the x and y of the END of the Range of Selection? (If it matters, I need it to run in standard text and also when the text is in a word Table)Code: [Select]Dim Left, Right, Top, Bottom Set Starting = Selection.Range Starting.SetRange Starting.Start, Starting.Start Left = Starting.Information(wdHorizontalPositionRelativeToPage) Top = Starting.Information(wdVerticalPositionRelativeToPage) Set Ending = Selection.Range Ending.SetRange Ending.End, Ending.End Right = Ending.Information(wdHorizontalPositionRelativeToPage) Bottom = Ending.Information(wdVerticalPositionRelativeToPage) 'MessageBox.Show "Left:" + Left + " Top:" + Top + " Right:" + Right + " Bottom:" + Bottom
Of course the "End" of the selection could be anywhere, so this wouldn't give you a rectangle in most cases. I couldn't figure out how to get the actual width/height of the selection itself.Thank you!! Thank you!!
|