msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ActiveX component can't create object

 
Post new topic   Reply to topic    msvisual.com Forum Index -> OLE Automation
Author Message
DrLargePants



Joined: 04 Oct 2007
Posts: 1

PostPosted: Wed Jun 27, 2007 1:36 pm    Post subject: ActiveX component can't create object Reply with quote

Any ideas why something like

Dim test As MyLib.MyClass
Set test = new MyLib.MyClass

Works fine, but

Dim test as object
Set test = createobject("MyLib.MyClass")

Fails with "ActiveX component can't create object"

Archived from group: microsoft>public>vb>ole>automation
Back to top
View user's profile Send private message
Ralph



Joined: 04 Oct 2007
Posts: 4148

PostPosted: Thu Jun 28, 2007 4:54 pm    Post subject: Re: ActiveX component can't create object Reply with quote

"DrLargePants" wrote in message@q75g2000hsh.googlegroups.com...
> Any ideas why something like
>
> Dim test As MyLib.MyClass
> Set test = new MyLib.MyClass
>
> Works fine, but
>
> Dim test as object
> Set test = createobject("MyLib.MyClass")
>
> Fails with "ActiveX component can't create object"
>

Most likely because the ProgID "MyLib.MyClass" is not registered or the
registration of the ClsID contains a different ProgID.

While both arguments appear identical for the Declaration and the
CreateObject Call they are not the same thing.
In ...
Dim test As MyLib.MyClass
"MyLib.MyClass" will be resolved to the identifier in the typelib that you
referenced. Note: No quotes - it is an type identifier.
In ...
CreateObject("MyLib.MyClass")
"MyLib.MyClass" will be resolved to the ProgID registered by that name in
the Registry. Note the quotes - it is a string.

This will become clearer if you open RegEdit and then search for
"MyLib.MyClass". You should see it defined under Hkey...\Classes\ and
Hkey...\ProgID. Or rather in your case you will likely find some
descrepancy.

Related to the above, you can experience this if you wrote the COM component
and failed to provide a Dual or IDispatch inteface.

-ralph

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    msvisual.com Forum Index -> OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group