ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Format in text boxes with multiple text lines (https://www.excelbanter.com/excel-programming/434019-format-text-boxes-multiple-text-lines.html)

Jess

Format in text boxes with multiple text lines
 
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?


joel

Format in text boxes with multiple text lines
 
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(msoTextOrientation Horizontal, _
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

"Jess" wrote:

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?



All times are GMT +1. The time now is 08:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com