
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?