Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ron ron is offline
external usenet poster
 
Posts: 118
Default Text Box Question

I have several text boxes on a worksheet that I'd like to loop through
and collect the input.

my_info=activesheet.textbox1

collects the information in textbox1. The following loop successfully
collects the data from all 6 text boxes.

n = 0 ' array is option base 0
For x = 1 To 6
my_info = ActiveSheet.OLEObjects("TextBox" & x).Object
ReDim Preserve retire_array(n)
info_array(n) = yy
n = n + 1
Next

My question is, is there a more concise construction then "my_info =
ActiveSheet.OLEObjects("TextBox" & x).Object" that I could use? I've
tried things like

my_info = activesheet.textbox(x)
my_info = activesheet.textboxes(x).text
my_info = activesheet.textboxes(x)
my_info = activesheet.textboxes(x).text

but none of these work. Is there some short construct other than the
one above using the Objects.object approach that will work?..TIA, Ron
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Text Box Question

You can also reference ActiveX objects as a Shape object, then via
sh.DrawingObject, but to read the text property you will still have to go
via the Object property of the OLEObject.

In passing, if you know (for certain as it seems) why the Redim Preserve.
Here's a couple of other ideas

Sub Test()
Dim arrTB() As Object
Dim colTB As Collection

ReDim arrTB(1 To 3)
Set colTB = New Collection

With ActiveSheet.OLEObjects
For i = 1 To 3
Set arrTB(i) = .Item("Textbox" & i).Object
colTB.Add .Item("Textbox" & i).Object, "Textbox" & i
Next
End With

MsgBox arrTB(1).Text
MsgBox colTB(2).Text
MsgBox colTB("Textbox3").Text

End Sub

Regards,
Peter T


"ron" wrote in message
...
I have several text boxes on a worksheet that I'd like to loop through
and collect the input.

my_info=activesheet.textbox1

collects the information in textbox1. The following loop successfully
collects the data from all 6 text boxes.

n = 0 ' array is option base 0
For x = 1 To 6
my_info = ActiveSheet.OLEObjects("TextBox" & x).Object
ReDim Preserve retire_array(n)
info_array(n) = yy
n = n + 1
Next

My question is, is there a more concise construction then "my_info =
ActiveSheet.OLEObjects("TextBox" & x).Object" that I could use? I've
tried things like

my_info = activesheet.textbox(x)
my_info = activesheet.textboxes(x).text
my_info = activesheet.textboxes(x)
my_info = activesheet.textboxes(x).text

but none of these work. Is there some short construct other than the
one above using the Objects.object approach that will work?..TIA, Ron



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
text format question JH Excel Discussion (Misc queries) 2 April 24th 09 06:21 PM
Text to Columns Question Dennis Excel Worksheet Functions 8 December 30th 05 12:52 PM
Text box question Greg B... Excel Discussion (Misc queries) 0 March 1st 05 07:28 AM
Text box question Greg B... Excel Discussion (Misc queries) 3 February 27th 05 02:47 PM
Text Box Question Rich Cooper Excel Programming 3 June 14th 04 11:51 PM


All times are GMT +1. The time now is 06:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"