How to fit a text box to the text (in a macro)?

J

João Correia

Hi,
I have a macro that builds a textbox, like this:


Sub Textbox()

Dim newTextbox As Shape
Dim t As Long

'localização do cursor
(wdHorizontalPositionRelativeToTextBoundary)
t = Selection.Information
(wdVerticalPositionRelativeToPage)

' add a text box
Set newTextbox = ActiveDocument.Shapes.AddTextbox _
(Orientation:=msoTextOrientationHorizontal,
Left:=130, Top:=t, Width:=300, Height:=20)


End Sub

I´d like to know what can I do to make the Height extend
to fit the text. If the text introduced by the user has
only one line, this height is fine, but if the text is
bigger, the textbox should get bigger too.

Thanks,

joão
 

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