Josh Hazel
06-29-2010, 04:14 PM
If I am wanting to learn how to add controls to a userform, where do I get a proper listing for syntax on something like this:
Set cControl = Me.Controls.Add("Forms.TextBox.1", "MyTextBox", True)
Highlighted in red, since the intellisense doesn't seem to explain this and Ive been googling for 30 minutes, I just need to know where I can find out that for a label I use "Forms.Label.1" or textbox "Forms.TextBox.1"
I know it sound self explanatory, but First of all dont know what the requirement of "Forms" is and why there is a ".1" and the end of it instead of just using "TextBox"
Edit:
This gives some different form names, but still doesnt seem to explain why it has Forms and 1 at the beginning and end of the string
http://pubs.logicalexpressions.com/pub0009/LPMArticle.asp?ID=259
Cerian Knight
06-29-2010, 05:09 PM
I find this list of ProgIDs on MSDN: http://msdn.microsoft.com/en-us/library/ee414765%28office.12%29.aspx
...for what it is worth.
Josh Hazel
06-29-2010, 08:24 PM
Also, the only way to create a new userform is to allow access to the vba project and add the reference to the vb for app extensibility reference?
it seems i was able to break the create new userform by using the VBE .add() method and naming it, then running it again (obv err i think cuz same userform name) but notice even after deleting the userform, you still cant use the same sub to create another userform with that name .. seems kinda flaky
Colin Legg
06-30-2010, 01:55 AM
Also, the only way to create a new userform is to allow access to the vba project and add the reference to the vb for app extensibility reference?
From a VBA'er perspective, why do you need to add a userform to the project at runtime anyway? It can be added at design time and, if necessary, stored in a template.
Highlighted in red, since the intellisense doesn't seem to explain this and Ive been googling for 30 minutes, I just need to know where I can find out that for a label I use "Forms.Label.1" or textbox "Forms.TextBox.1"
In addition to CK's link, quite a few are listed in the VBA helpfile under the Controls.Add Method topic:
Settings
ProgID values for individual controls are:
CheckBox Forms.CheckBox.1
ComboBox Forms.ComboBox.1
CommandButton Forms.CommandButton.1
Frame Forms.Frame.1
Image Forms.Image.1
Label Forms.Label.1
ListBox Forms.ListBox.1
MultiPage Forms.MultiPage.1
OptionButton Forms.OptionButton.1
ScrollBar Forms.ScrollBar.1
SpinButton Forms.SpinButton.1
TabStrip Forms.TabStrip.1
TextBox Forms.TextBox.1
ToggleButton Forms.ToggleButton.1
Hope that helps...
Visvang
06-30-2010, 09:56 AM
I also had that problem and did find something on google and edit it here is my edited version
Cerian Knight
06-30-2010, 12:00 PM
For more clarity, the ProgIDs are registered classes that can be found in the Registry under HKEY_CLASSES_ROOT. If a new expanded version of the class became available the original .1 would normally still be present, but a .2 (or such) would also be available.
Josh Hazel
06-30-2010, 02:38 PM
[QUOTE=Colin Legg;1365368]From a VBA'er perspective, why do you need to add a userform to the project at runtime anyway? It can be added at design time and, if necessary, stored in a template.
QUOTE]
Mostly for learning. Ive been self teaching myself for about a year in a half (obviously is going quite slowly, if im still asking these prol ez Q) if I learn the more complicated method seems like it would better help me long term learn
But the logistics of this are telling me to use a blank userform and just create controls rather than the other way around. I am basically attempting to create my own Msgbox that will allow manipulating # of buttons, # of labels, and code behind the labels, etc ... also trying to do this using a class, as I really want to learn classes since they are prol one of most useful things in the programming world