Format in text boxes with multiple text lines

J

Jess

I have an excel application which automatically adds textboxes when the user
clicks on a button. Each text box must accommodate two text lines: an upper
one and a lower one.

The upper line has bold 12-size bold arial font. This text line (text &
format) is generated by the code. The lower line is typed in by the user and
it must have a predefined format. I would like this line to be ready for my
users to start typing.

I would like to implement the following behavior in each textbox: whenever
the user clicks on the textbox the cursor must be on the lower text line,
which must have italic 10-size bold times new roman font: this lower line is
already formatted for the user to start typing. How can I accomplish this?
 
J

Joel

This will work. I'm not sure which type texttboxes yo are dealing with. The
olebojects didn't work for me but this did.

Sub test()

Set NewBox = Worksheets(1).Shapes.AddTextbox(msoTextOrientationHorizontal, _
100, 100, 200, 50)

With NewBox.TextFrame
FirstRow = "Joel"
.Characters.Text = FirstRow & Chr(10)
BoxLen = Len(.Characters.Text)

.Characters(Start:=1, Length:=4).Font.Size = 12
.Characters(Start:=BoxLen, Length:=1).Font.Size = 10
End With

End Sub
 

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