One last TextBox question

  • Thread starter Patrick C. Simonds
  • Start date
P

Patrick C. Simonds

Is there any way to adjust the height of an ActiveX TextBox, so that it is
only the height of the font used in the TextBox. I try adjusting the height
but it's like there is a space above and below the text (like a line
spacing).
 
J

JCNZ

Hi Patrick:

This assumes that your textbox is the first Shape in the activedocument:

Sub FF()
Dim myshp As Shape
Set myshp = ActiveDocument.Shapes(1)
With myshp
'Set the textbox margins to zero
With .TextFrame
.MarginBottom = 0
.MarginTop = 0

'Set the paragraph spacing to zero
With .TextRange.ParagraphFormat
.SpaceAfter = 0
.SpaceBefore = 0
End With
End With

'Shrink the height until the text overflows
Do While Not .TextFrame.Overflowing
.Height = .Height - 1
Loop

'Then add 1pt to the height to stop overflowing
.Height = .Height + 1
End With
End Sub

Cheers.

JCNZ
 

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