ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   HOW TO SELECT THE TEXT BOX? (https://www.excelbanter.com/excel-programming/433531-how-select-text-box.html)

ezil

HOW TO SELECT THE TEXT BOX?
 
My application needs copying text box contents (eg.text box 1) from sheet 1
to antoher text box in sheet 2. For that i tried to select text box but i
found it is not possible. What is the code for this task? (The text box is
ordinary text box and not the text box from active control or form control)


JP Ronse

HOW TO SELECT THE TEXT BOX?
 
Hi,

Do you mean a textbox from the drawing toolbar?

Try

Activesheet.shapes.count, this should return the number of shapes in the
worksheet.

Next, you can get the names of the shapes with

activesheet.shapes(x).name with x is a number between 1 and the result of
the .count instruction.

To select: activesheet.shapes(x).select

With
selection.characters.text you can read or set the text.

Something as

Sub AAAA
Dim str As String

With ActiveSheet
.Shapes("Text Box 3").Select
str = Selection.Characters.Text
.Shapes("Text Box 2").Select
Selection.Characters.Text = str
End With

End Sub


should do what you want.

Wkr,

JP

"ezil" wrote in message
...
My application needs copying text box contents (eg.text box 1) from sheet
1
to antoher text box in sheet 2. For that i tried to select text box but i
found it is not possible. What is the code for this task? (The text box is
ordinary text box and not the text box from active control or form
control)




Rick Rothstein

HOW TO SELECT THE TEXT BOX?
 
Try it like this...

Worksheets("Sheet2").TextBoxes("Text Box 1").Text = _
Worksheets("Sheet1").TextBoxes("Text Box 1").Text

where you would use the appropriate worksheet names in place of my "Sheet1"
and "Sheet2" example names and the appropriate Text Box names in place of my
example "Text Box 1" and "Text Box 2".

--
Rick (MVP - Excel)


"ezil" wrote in message
...
My application needs copying text box contents (eg.text box 1) from sheet
1
to antoher text box in sheet 2. For that i tried to select text box but i
found it is not possible. What is the code for this task? (The text box is
ordinary text box and not the text box from active control or form
control)



Rick Rothstein

HOW TO SELECT THE TEXT BOX?
 
By the way, if you are unsure of how to get the names Excel assigns to its
Shape objects (whether they be Text Boxes or any other shape object), simply
select the shape object and then execute this statement in the VB editor's
Immediate window...

? Selection.Name

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
Try it like this...

Worksheets("Sheet2").TextBoxes("Text Box 1").Text = _
Worksheets("Sheet1").TextBoxes("Text Box 1").Text

where you would use the appropriate worksheet names in place of my
"Sheet1" and "Sheet2" example names and the appropriate Text Box names in
place of my example "Text Box 1" and "Text Box 2".

--
Rick (MVP - Excel)


"ezil" wrote in message
...
My application needs copying text box contents (eg.text box 1) from sheet
1
to antoher text box in sheet 2. For that i tried to select text box but i
found it is not possible. What is the code for this task? (The text box
is
ordinary text box and not the text box from active control or form
control)





All times are GMT +1. The time now is 10:15 PM.

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