Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

accessing controls

Status
Not open for further replies.

rgandy

Technical User
Nov 17, 2005
38
US
i am wondering whether there is a way for a control to be accessed via a string

ie.
i have a drop down called condition1_1. these increment up to condition1_4

is there a way to access all 4 and assign them via a property?

for x = 1 to 4
Set testarray(x)= VBAProject(Sheet1 "Condition1_" & x)
next x

the above code fails. any suggestions?

thanks very much
 



Hi,

Use the Controls() object and concatenate the Number in the name...
Code:
for x = 1 to 4
   testarray(x) = sheet1.controls("condition1_" & x) 
next x
BTW, SET is used for OBJECTS.

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 



actually, If its on a sheet...
Code:
for x = 1 to 4
   testarray(x) = sheet1.shapes("condition1_" & x) 
next x

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
guys,
unfortunately this code does not work...it requires that i pull a property of the shape to set it to a value in the array

how can i do this so that i can get the value contained in the drop down? the shape doesnt have a text or value property

thanks!
 
seems this works

QueryArray(GenericLoop, GenericLoopB) = Sheet1.Shapes(QueryNameArray(GenericLoopB) & "_" & GenericLoop).OLEFormat.Object.Object.Value
 


Sorry...
Code:
for x = 1 to 4
   testarray(x) = sheet1.shapes("condition1_" & x).oleformat.object.value 
next x

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
QueryArray and QueryNameArray are not found in my VBA 2003/ intelisense/ Help; are these undocumented procedures?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top