Creating ActiveX control at run-time

I have no experience with VB. I need to create ActiveX control at run-time. I tried to use GetObject and CreateObject passing ProgID. Object is created successfully. But then I cannot call any of its methods or set any of its properties. I even can't show it if I set Visible control window property to true. I get run-time error "Object doesn't support this method".

Below is my piece of code

Dim objChart As Object
Set objChart = GetObject("", "mschartlib.mschart")
objChart.Visible = True
LVL 7
galkinAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
chitnisConnect With a Mentor Commented:
Activex controls cannot be created at runtime.You have to load at least one controlmyocx(0) on the form at design time,Set its index property to 0 and then create a control array by saying
  load myocx(1)
0
 
ndbCommented:
You should try to make a new object:
Dim objChart As New Object
0
 
galkinAuthor Commented:
I tried your solution and I get compiler error "Expected: identifier"
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
percosolatorCommented:
got the doesn't support this property or method.

why do you need to create it at run-time?  Why not use early binding?
0
 
galkinAuthor Commented:
I try to change control window properties, for instance Visible. In this case I get error that property or method is not supported bu the control. If I call really control method or set proprty I get OLE run-time error.
I do need to create ActiveX control at run-time. I guessed it is very basic simple task, in C++ I would do it in 10 seconds.
0
 
galkinAuthor Commented:
Could you give me an example. I am absolutely not familiar with VB syntax.
0
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.