determine height of text box in MS Word 2003

I have the following code to create a text box around some text and set its width:
Selection.ShapeRange(1).Width = InchesToPoints(7.3)

Open in new window

Now I need to determine the length or number of lines in the selection to determine the height of the text box:
     Selection.ShapeRange(1).Height = ??

Any ideas?  TIA
LVL 39
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Personally I don't think I would do it like that, but this does work.

Selection.Font.Size * Selection.Paragraphs(1).Range.ComputeStatistics(wdStatisticLines) + (Selection.ParagraphFormat.SpaceAfter * Selection.Paragraphs(1).Range.ComputeStatistics(wdStatisticLines) - 1)

Open in new window

This might be what you need:
Dim sh As Shape
Set sh = Selection.ShapeRange(1)
sh.Width = InchesToPoints(7.3)
sh.TextFrame.AutoSize = True

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
thenelsonAuthor Commented:
That worked!

I used:
Selection.ShapeRange(1).Height = (Selection.Range.ComputeStatistics(wdStatisticLines) + 1) * 12

but your suggestion of:
sh.TextFrame.AutoSize = True

I believe is more reliable and cleaner.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.