Adding Controls To TabStrip On UserForm

HighAndWilder

Well-known Member
Joined
Nov 4, 2006
Messages
712
Office Version
  1. 365
Platform
  1. 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
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
A TabStrip isn't a container control like a Frame so they don't have controls on/in them.
 
Last edited:
Upvote 0
The TabStrip Control allows me to add listboxes, textboxes etc to it and they behave in exactly the same way as if they were directly on the userform so I don't understand why I cannot add these at run time.
 
Upvote 0
You aren't adding them to the TabStrip, you are adding them to the userform.

A TabStrip cannot 'contain' other controls, as such it does not have a Controls property.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,180
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top