Get coordinates in points of text (or placed object) on screen. 
Author Message
 Get coordinates in points of text (or placed object) on screen.

You guys are my last hope.  I want to program transclusions.
This is the same piece of text that is in two different documents.
Edit it in one document and it changes correspondingly in the
other document.  A transclusion is shown by a line when the documents
are shown side by side.

Unfortunately, I have found no way to get the coordinates in points of a
letter or any body of text on the screen.  

I have come up empty in these ways:
- The anchor for a shape is the beginning of the paragraph.  Yuck!
- I have not found any object I can insert i.e. bookmark, where I can
get the coordinates of that object.
- The 'Size' property would give me the vertical length of a character,
but VBA is missing the 'TextWidth' method, that was in previous
versions of Visual Basic, it seems.  If I had the 'TextWidth' method
I would be able to go character by character find the point where my
line should go (ugly method, but I'd take it).
- The 'Frame' object can not be aligned inside the body of text.  Nor
does it seem possible to align exactly any object inside the body of
text.  

Does anybody have any ideas?  Or is what I'm trying to do inside Microsoft
Word actually impossible?



Mon, 19 Jan 2004 10:49:34 GMT  
 Get coordinates in points of text (or placed object) on screen.
Hi Brent,

Word VBA doesn't offer you the ability to get the coordinates relative to
the screen window, but you can get the coordinates relative to the printed
page. The following 2 lines will give you the coordinates of the active end
of the selection in points relative to the top left corner of the page,
provided the selection is currently visible in the editing window, and
provided you are in page view.

x = Selection.Information(wdHorizontalPositionRelativeToPage)
y = Selection.Information(wdVerticalPositionRelativeToPage)

--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
Word FAQs at http://www.multilinker.com/wordfaq
Please post any follow-up in the newsgroup. I do not reply to Word questions
by email


Quote:
> You guys are my last hope.  I want to program transclusions.
> This is the same piece of text that is in two different documents.
> Edit it in one document and it changes correspondingly in the
> other document.  A transclusion is shown by a line when the documents
> are shown side by side.

> Unfortunately, I have found no way to get the coordinates in points of a
> letter or any body of text on the screen.

> I have come up empty in these ways:
> - The anchor for a shape is the beginning of the paragraph.  Yuck!
> - I have not found any object I can insert i.e. bookmark, where I can
> get the coordinates of that object.
> - The 'Size' property would give me the vertical length of a character,
> but VBA is missing the 'TextWidth' method, that was in previous
> versions of Visual Basic, it seems.  If I had the 'TextWidth' method
> I would be able to go character by character find the point where my
> line should go (ugly method, but I'd take it).
> - The 'Frame' object can not be aligned inside the body of text.  Nor
> does it seem possible to align exactly any object inside the body of
> text.

> Does anybody have any ideas?  Or is what I'm trying to do inside Microsoft
> Word actually impossible?



Mon, 19 Jan 2004 22:52:52 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How do I coordinate the screen's coordinates with a form coordinate

2. Mapping listview coordinates to screen coordinates

3. Converting container-relative coordinates to screen coordinates

4. Container-relative coordinates to screen coordinates

5. How to get coordinates from various screen objects

6. Getting Color Values of specific points on screen

7. Screen Coordinates: How to place form where mouse is pointing???

8. Screen coordinates change after changing screen resolution???

9. NEWBIE : Getting Error Object required Can anyone point out whats wrong

10. Getting the Path to a picture placed on an object

11. VB4 16-bit Commondialog File Dialogbox placed outside screens on NT4 with two screens

12. Coordinates of mouse pointing ??!!

 

 
Powered by phpBB® Forum Software