Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2007

Tip: Looking for answers? Try searching our database.

Word Selection and Ranges - dimensions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Simon Woods - 05 Apr 2007 15:17 GMT
Hi

Is there a way to find out programmatically the dimensions of a selected
range. Obviously if I select a range of text and insert a textbox, Word
knows how big to make that textbox and places all that text into the a
correctly sized textbox. That is the information I'm trying to get hold of.

I'm looking at the active Selection and Range objects in the Watch window
but there's nothing obvious to give a clue as to the height and width. I've
tried recording a macro to see what goes on behind the scenes but it didn't
give me much help.

Thanks

Simon
Stefan Blom - 05 Apr 2007 15:33 GMT
A range is defined by its Start and End properties; see Word VBA Help
and http://word.mvps.org/FAQs/MacrosVBA/index.htm.

Signature

Stefan Blom
Microsoft Word MVP

> Hi
>
[quoted text clipped - 11 lines]
>
> Simon
Simon Woods - 05 Apr 2007 15:53 GMT
> "Simon Woods" wrote in message
>>
[quoted text clipped - 8 lines]
>> and width. I've tried recording a macro to see what goes on behind
>> the scenes but it didn't give me much help.

> A range is defined by its Start and End properties; see Word VBA Help
> and http://word.mvps.org/FAQs/MacrosVBA/index.htm.

Thanks Stefan.

As I'm trying to get the dimensions of the range but the range includes
images as well as text. I wondered whether I could get the position of the
start char on the page and get the position of the end char on the page but
there's a problem if there is a graphic which is locate to the right or
bottom of the last char. Similar is there is a graphic situated to the left
or top of the start char.

Am I missing something in what you're suggesting. Or will I need to do the
math and work out the position of inline shapes relative to the text to see
if either of these scenarios apply?

Thanks

Simon
Stefan Blom - 10 Apr 2007 08:06 GMT
A range in itself does not have a "size" other than its start and end
properties; the actual space it occupies depends on the size of text
(including any inline objects).

As far as I know, the only way to get the position of the insertion
point on a page is to use the Information property:

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

Signature

Stefan Blom
Microsoft Word MVP

> > "Simon Woods" wrote in message
> >>
[quoted text clipped - 28 lines]
>
> Simon
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.