Text Box name

tasander

Board Regular
Joined
Mar 6, 2009
Messages
67
Hi

I am creating a text box in a macro but later on want to grab that text box again, how can i give the text box a name on initial creation so that i can go back to it later?

Thanks
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi,

Code:
i = Application.InputBox("Please enter value", "Enter Value", Type:=1)

This works for me...it calls an input box that I recall more times when need it.

Roberto.
 
Upvote 0
Welcome to the Board.

Example:

Code:
Sub T()
    Dim Sh As Shape
    Set Sh = ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, 224.25, 110.25, _
        134.25, 82.5)
    Sh.Name = "MyTextBox"
End Sub
 
Upvote 0
Thanks for the quick responses guys, can you advise how i can then grab the text box and enter text or change the appearance.

Thanks
 
Upvote 0
To enter text and set the fill colour:

Code:
Sub AddTextBox()
    Dim Sh As Shape
    Set Sh = ActiveSheet.Shapes.AddTextBox(msoTextOrientationHorizontal, 224.25, 110.25, _
        134.25, 82.5)
    Sh.Name = "MyTextBox"
End Sub
Sub FormatTextBox()
    With ActiveSheet.Shapes("MyTextBox")
        .TextFrame.Characters.Text = "Hello there!"
        .Fill.ForeColor.SchemeColor = 10
    End With
End Sub

Using the macro recorder will give you what you need.
 
Upvote 0

Forum statistics

Threads
1,214,525
Messages
6,120,051
Members
448,940
Latest member
mdusw

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