Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
424 Error whem trying to change Visible property
Why am I getting an Run time error 424 when trying to change the visible
properties in a control which is loaded into a collection. The collection is dim'd as a Public variable. I am trying to change this property within a click event of a button on the form Public cntrlclctn1 As Collection Private Sub CommandButton1_Click() Dim x As Integer For x = 1 To cntrlclctn1.Count cntrlclctn1(x).Visible = True Next End Sub Sub thing() Dim lbl As Control Dim txtbx As Control 'Create controls Set lbl = UserForm1.Controls.Add("Forms.Label.1") lbl.Caption = "Label Text" lbl.Visible = False Set txtbx = UserForm1.Controls.Add("Forms.TextBox.1") txtbx.Text = "Text Box Text" txtbx.Visible = False 'Add controls to collection Set cntrlclctn1 = New Collection cntrlclctn1.Add (lbl) cntrlclctn1.Add (txtbx) UserForm1.Show End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
424 Error whem trying to change Visible property
Remove the brackets...
Set cntrlclctn1 = New Collection cntrlclctn1.Add lbl cntrlclctn1.Add txtbx With the brackets you are passing the default property instead of the object itself... -- HTH... Jim Thomlinson "ExcelMonkey" wrote: Why am I getting an Run time error 424 when trying to change the visible properties in a control which is loaded into a collection. The collection is dim'd as a Public variable. I am trying to change this property within a click event of a button on the form Public cntrlclctn1 As Collection Private Sub CommandButton1_Click() Dim x As Integer For x = 1 To cntrlclctn1.Count cntrlclctn1(x).Visible = True Next End Sub Sub thing() Dim lbl As Control Dim txtbx As Control 'Create controls Set lbl = UserForm1.Controls.Add("Forms.Label.1") lbl.Caption = "Label Text" lbl.Visible = False Set txtbx = UserForm1.Controls.Add("Forms.TextBox.1") txtbx.Text = "Text Box Text" txtbx.Visible = False 'Add controls to collection Set cntrlclctn1 = New Collection cntrlclctn1.Add (lbl) cntrlclctn1.Add (txtbx) UserForm1.Show End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
424 Error whem trying to change Visible property
Thanks Jim.
EM "Jim Thomlinson" wrote: Remove the brackets... Set cntrlclctn1 = New Collection cntrlclctn1.Add lbl cntrlclctn1.Add txtbx With the brackets you are passing the default property instead of the object itself... -- HTH... Jim Thomlinson "ExcelMonkey" wrote: Why am I getting an Run time error 424 when trying to change the visible properties in a control which is loaded into a collection. The collection is dim'd as a Public variable. I am trying to change this property within a click event of a button on the form Public cntrlclctn1 As Collection Private Sub CommandButton1_Click() Dim x As Integer For x = 1 To cntrlclctn1.Count cntrlclctn1(x).Visible = True Next End Sub Sub thing() Dim lbl As Control Dim txtbx As Control 'Create controls Set lbl = UserForm1.Controls.Add("Forms.Label.1") lbl.Caption = "Label Text" lbl.Visible = False Set txtbx = UserForm1.Controls.Add("Forms.TextBox.1") txtbx.Text = "Text Box Text" txtbx.Visible = False 'Add controls to collection Set cntrlclctn1 = New Collection cntrlclctn1.Add (lbl) cntrlclctn1.Add (txtbx) UserForm1.Show End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Runtime error 1004 - unable to set Visible property of Worksheet c | Excel Programming | |||
Error:Unable to set the visible property of the PivotItem class. | Excel Programming | |||
.visible property causing an error in Excel 97 | Excel Programming | |||
Visible Property | Excel Programming | |||
Run-time error '1004' - Unable to set the Visible property of the Worksheet class | Excel Programming |