Select textbox from inside

D

dange

Hi all

My macro starts when the user has selected something inside a textbox.
How can I find out the height of the textbox I'm currently inside?

Thanks for your help

Dan
 
K

Kevin B

You can get that information from the shape as a shape range object:

Sub TheShape()

Dim doc As Document
Dim dblHeight As Double
Dim dblWidth As Double
Dim strName As String
Dim strHeight As String
Dim strWidth As String
Set doc = ThisDocument

strName = Selection.ShapeRange.Name
strHeight = Selection.ShapeRange.Height
strWidth = Selection.ShapeRange.Width

MsgBox "The text box is " & strHeight & _
" points tall and " & strWidth & _
" points wide and is named " & strName



End Sub
 
K

Kevin B

Ignore the variable declartions for dblHeight and dblWidth as they're not
used in the macro.
 
D

dange

Thanks for your quick answer.
This works fine if the selection is a text.
But when another shape is inside the textbox and the shape is selected, I
get of corse the size of the selected shape.
How to get the height of the textbox in this case?

Thanks again
Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top