I have following method which I am using to load ActiveX control dynamically,
Dim ctl As Control
Set ctl = Form1.Controls.Add("prog.id", "myctl")
ctl.Visible = True
Using this code control successfully display on the form, but when I try to access methods/properties of control ctl.mymethod() its give the error, “Object doesn’t support this method or property”.
Secondly when I use this approach
Dim ctl As Object
Set ctl = CreateObject("prog.id")
Ctl.mymethod()
Here method successfully called from control, but I can’t display this object on form.
Kindly tell me any solution about this issue.
Edit:
Using the following approch its also giving the error when I call methods, “Object does’t support……..”
Dim ctl As Object
Set ctl = Controls.Add("prog.id", "myctl")
ctl.Visible = True
Don’t declare the reference as
Control. That will only let you access theControlinterface members.Try declaring
ctlasObjectinstead and it will then be fully late bound.