I know how to add a form control to a userform at runtime. I
want to know how to add a "custom" ActiveX control at
runtime. Anybody?
I know how to add a form control to a userform at runtime. I
want to know how to add a "custom" ActiveX control at
runtime. Anybody?
Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
<img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

This month, every Windows Secrets subscriber can download a one-chapter excerpt of Windows 7: The Missing Manual.Windows 7: The Missing Manual provides valuable information to help you overcome these difficulties in learning a new operating system. Subscribe today to download your free excerpt.
AFAIK, the custom control has to be registered. That is, you must be able to find the control's ProgID in the Windows Registry under HKEY_CLASSES_ROOT.
Then you can use code like
Dim ctl As Control
Set ctl = Me.Controls.Add("MyProgID", "MyCtl", True)
With ctl
.Width = 200
' etc.
End With
"MyProgID" is the ProgID, "MyCtl" is the name of the control (if omitted, VB assigns a standard name) and True indicates that the control will be visible (can be omitted, True is default).
For example, to create a calendar control:
Set c = Me.Controls.Add("MScal.Calendar", "MyCal", True)
Hans,
Thanks. I think your calendar control example puts me on track!
Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
<img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>