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
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 -- Kevin Backmann "dange" wrote: > 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
Ignore the variable declartions for dblHeight and dblWidth as they're not used in the macro. -- Kevin Backmann "Kevin B" wrote: > 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 > -- > Kevin Backmann > > > "dange" wrote: > > > 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
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 "Kevin B" wrote: > 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 > -- > Kevin Backmann > > > "dange" wrote: > > > 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