Issue with MSForms (Office 2003, XP Pro)

User avatar
AlanMiller
BronzeLounger
Posts: 1545
Joined: 26 Jan 2010, 11:36
Location: Melbourne, Australia

Issue with MSForms (Office 2003, XP Pro)

Post by AlanMiller »

I suspect I may have an issue with the wrong version of fm20.dll - 12.0.6510.5004. When I try to do something like :
.Add("MSForms.TextBox.1", "MyTextBox", Visible)
I receive an error for an invalid class string. Intellisense does confirm that .TextBox is not avialable - all displayed properties and methods are prefixed with "fm". I can see that there were some issues with this file during automatic updates. Does anybody have more info and the correct version, if appropriate?

Alan

User avatar
HansV
Administrator
Posts: 78233
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Issue with MSForms (Office 2003, XP Pro)

Post by HansV »

Try

.Add("Forms.TextBox.1", "MyTextBox", Visible)

The ProgID strings for userform controls are all of the form Forms.typename.1
Best wishes,
Hans

User avatar
AlanMiller
BronzeLounger
Posts: 1545
Joined: 26 Jan 2010, 11:36
Location: Melbourne, Australia

Re: Issue with MSForms (Office 2003, XP Pro)

Post by AlanMiller »

Thanks Hans. Right on the money again. As you can tell, I'm rather rusty with my VBA :blush:. Now I'm curious where the MSForms fits in. What do all those properties & methods on the intellisense dropdown refer to?

thanks again
Alan

User avatar
HansV
Administrator
Posts: 78233
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Issue with MSForms (Office 2003, XP Pro)

Post by HansV »

MSForms is the class name of the object library, so you can use a declaration like this:

Dim obj As MSForms.TextBox

and typing MSForm followed by a period in the Visual Basic Editor will show the type names of controls; these are subclasses of the MSForms class.

When using the Add method to create a control, you have to specify the ProgID string of the control type; this is different from the above.
Best wishes,
Hans