VBA--drawing textbox...change text.

repairman615

Well-known Member
Joined
Dec 21, 2009
Messages
1,885
Hello,

I am using 2007 and am trying to control the text of a textbox choosen off the insert menu.
Code:
Sheets(1).Shapes("textbox 12").Text = "hello"
Using this line gives error 438. Object doesn't support this property or method.

My goal is to basically have a macro fire when only cell a1 is changed, and if a1 is greater than 3000 then change textbox 12, else textbox 12 = "".

All help and comments are greatly appreciated.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
BTW

You can address the individual characters in the text box, and any other shapes that have a text frame with something like this:

Code:
Sheets(1).Shapes("textbox 12").TextFrame.Characters.Text = "HELLO"

'Starting at the 3rd character and continuing for 2 characters change the font color & bold
Sheets(1).Shapes("textbox 12").TextFrame.Characters(3, 2).Font.Color = RGB(255, 0, 0)
Sheets(1).Shapes("textbox 12").TextFrame.Characters(3, 2).Font.Bold = True

Gary
 
Upvote 0
Try this:

Code:
Sheets(1).Shapes("textbox 12").TextFrame.Characters.Text = "hello"

Hope it helps.

Gary

Old answer I know but this help me so I wanted to say so. I have looked around numerous websites and forums to find out how to do this "simple" thing, setting text in a textbox using vba. Thanks to this I have finally done it!
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top