ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Editing Text Boxes (https://www.excelbanter.com/excel-programming/392691-editing-text-boxes.html)

Kaval

Editing Text Boxes
 
I have created a text box named "TextBox_One" on sheet "Sheet_One" using the
following:

Sheets("Sheet_One").Shapes.AddTextbox(msoTextOrien tationHorizontal, 100,
100, 100, 400).Name = "TextBox_One"

I would like to edit the text box by adding text, changing borders etc but I
can't get the code to work. I have used the macro recorder to generate the
code but I do not want to select the object to perform the edits and I can't
seem to adapt the code to work.

For example, to add text I tried the following

Sheets("Sheet_One").Shapes("TextBox_One").Characte rs.Text = "Sample Text"

but got the error message "Object doesn't support this property or method"

Any help appreciated, Kaval

Bob Phillips

Editing Text Boxes
 
Here is an example

Dim oShp As Shape

Set oShp = Sheets("Sheet_One").Shapes.AddTextbox( _
msoTextOrientationHorizontal, 100, 100, 100, 400)
With oShp
.Name = "TextBox_One"
With .TextFrame.Characters
.Text = "hello"
.Font.Name = "Arial"
.Font.ColorIndex = 3
End With
With .Fill
.Visible = msoTrue
.Solid
.ForeColor.SchemeColor = 65
.Transparency = 0#
End With
With .Line
.Weight = 1.5
.DashStyle = msoLineSquareDot
.Style = msoLineSingle
.Transparency = 0#
.Visible = msoTrue
.ForeColor.SchemeColor = 12
.BackColor.RGB = RGB(255, 255, 255)
End With
End With

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Kaval" wrote in message
...
I have created a text box named "TextBox_One" on sheet "Sheet_One" using
the
following:

Sheets("Sheet_One").Shapes.AddTextbox(msoTextOrien tationHorizontal, 100,
100, 100, 400).Name = "TextBox_One"

I would like to edit the text box by adding text, changing borders etc but
I
can't get the code to work. I have used the macro recorder to generate the
code but I do not want to select the object to perform the edits and I
can't
seem to adapt the code to work.

For example, to add text I tried the following

Sheets("Sheet_One").Shapes("TextBox_One").Characte rs.Text = "Sample Text"

but got the error message "Object doesn't support this property or method"

Any help appreciated, Kaval





All times are GMT +1. The time now is 06:48 AM.

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