HighAndWilder
Well-known Member
- Joined
- Nov 4, 2006
- Messages
- 712
- Office Version
- 365
- Platform
- Windows
Hi
I'm trying to add a control (ListBox) to a Tabstrip.
I can add a control to a Frame but using the same technique I thought that I had it sussed. Apparently not.
Set Cmd = Frame1.Controls.Add("Forms.CommandButton.1", "cmd1")
Cmd.Left = 30
Cmd.Top = 70
Lbl.BackColor = RGB(224, 224, 224)
The above works fine where Cmd is declared as follows in the form module declaration area :
Private WithEvents Cmd As MSForms.CommandButton
Dim objTabSTrip As Object
Dim objListBoxNew As MSForms.ListBox
Set objTabSTrip = Me.Controls("tabTabStrip")
Set objListBoxNew = objTabSTrip.Controls.Add("Forms.ListBox.1", "lstListBoxNew")
The last line throws up an "Object doesn't support this property or method" error message.
Any ideas anybody?
I'm doing this in the forms UserForm_Activate procedure but I would like to do it in the code that I have set up to create the form on the fly.
Can anybody point me to some explanations on the web as to how I can do this? What I have found so far is fairly basic. I have already managed to create most
of the commonly used controls including TabStrips and Frames but cannot add controls to these.
Thanks
HighAndWilder
I'm trying to add a control (ListBox) to a Tabstrip.
I can add a control to a Frame but using the same technique I thought that I had it sussed. Apparently not.
Set Cmd = Frame1.Controls.Add("Forms.CommandButton.1", "cmd1")
Cmd.Left = 30
Cmd.Top = 70
Lbl.BackColor = RGB(224, 224, 224)
The above works fine where Cmd is declared as follows in the form module declaration area :
Private WithEvents Cmd As MSForms.CommandButton
Dim objTabSTrip As Object
Dim objListBoxNew As MSForms.ListBox
Set objTabSTrip = Me.Controls("tabTabStrip")
Set objListBoxNew = objTabSTrip.Controls.Add("Forms.ListBox.1", "lstListBoxNew")
The last line throws up an "Object doesn't support this property or method" error message.
Any ideas anybody?
I'm doing this in the forms UserForm_Activate procedure but I would like to do it in the code that I have set up to create the form on the fly.
Can anybody point me to some explanations on the web as to how I can do this? What I have found so far is fairly basic. I have already managed to create most
of the commonly used controls including TabStrips and Frames but cannot add controls to these.
Thanks
HighAndWilder