Excel Create object name for tab object of UserForm TabStrip. What is the data type for TAB?

I wish to add a tab to a tabstrip, dynamically at runtime, in an excel 2016 UserForm:
I need the Add Method:
Set tabXY = TabStrip1.Tabs.Add(tabName, tabCaption, tabIndex).

I got my code model from:
        Dim tabX As Tab
        Set tabX = tabData.Tabs.Add()

But, when I declare:
dim tabXY as tab, I am warned: "expected NEW, or TYPE NAME"

My VBE/VBA Project/References include:
Microsoft Forms 2.0 Object library
Microsoft Visual Basic for Applications Extensibility 5
The file has been saved and  reopened after adding ref '.... Extensibility 5'
Can you please explain?

Who is Participating?
Fabrice LambertConnect With a Mentor Fabrice LambertCommented:
I guess the compiler is confused, since there is a Tab data type in the Excel library.

Try fully qualifying your data type:
Dim tabX As MSForms.Tab

Open in new window

It is always a good idea to fully qualify your data types, it avoid confusion.
NorieConnect With a Mentor VBA ExpertCommented:
Try declaring it simply as Object.
Kelvin4Author Commented:
Super-fast solutions.  Both worked; Fabrice's taught me good practice and what had held me up.

Thank you both -
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.