Tinbendr
10-08-2009, 08:33 AM
Is there a way to interate the controls in the VBE, renaming the object name and the caption?
I tried this code.
Private Sub setup()
Dim aControl As Control
Dim Counter As Integer
For Each aControl In ufBenchStockPick.Controls
If aControl.Name Like "CommandButton*" Then
Counter = Counter + 1
'Rename control
aControl.Name = "cmdBS" & Right("00" + Trim(Counter), 3)
'Rename Caption of Control
aControl.Caption = Right("00" + Trim(Counter), 3)
End If
Next
End SubBut it stops at aControl.Name with "cannot change at runtime" error.
I can take out the name method and just let it rename the caption, but it doesn't change it on the VBE, just at Userfrom1.Show.
Thanks in advance!
I tried this code.
Private Sub setup()
Dim aControl As Control
Dim Counter As Integer
For Each aControl In ufBenchStockPick.Controls
If aControl.Name Like "CommandButton*" Then
Counter = Counter + 1
'Rename control
aControl.Name = "cmdBS" & Right("00" + Trim(Counter), 3)
'Rename Caption of Control
aControl.Caption = Right("00" + Trim(Counter), 3)
End If
Next
End SubBut it stops at aControl.Name with "cannot change at runtime" error.
I can take out the name method and just let it rename the caption, but it doesn't change it on the VBE, just at Userfrom1.Show.
Thanks in advance!