Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb reference to COM

Status
Not open for further replies.

smythe

Programmer
May 30, 2001
49
US
CreateObject
How do I use CreateObject in VB to instantiate a dll instead of doing it in the references. This should be simple, sorry I'm a c++ programmer.

For instance, I reference my Novar.dll in my references then use this code:


code:--------------------------------------------------------------------------------
Dim comSched As NOVAR2BCMLib.Novar
Set comSched = New NOVAR2BCMLib.Novar
--------------------------------------------------------------------------------

and everything works great. How can I accomplish the same thing without using a reference. I tried to to this:

code:--------------------------------------------------------------------------------
Dim comSched As Object
Set comSched = CreateObject("Novar2BCMLib.Novar")
--------------------------------------------------------------------------------


This does not work and complains

quote:
--------------------------------------------------------------------------------

Runtime error '429':
ActiveX component can't create object

--------------------------------------------------------------------------------



Also on a side note, NOVAR2BCM is a visual c++ COM/ATL component in case this is relevant.
 
The argument to CreateObject is the ProgID of your COM object, if that helps. The usual things apply: make sure your COM object is registered, etc.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Thanks, got it working. The COM object was registered properly, but I was simply using the wrong name for a parameter in the CreateObject function.

It needed to be
Set comSched = CreateObject("Novar2BCM.Novar")

instead of
Set comSched = CreateObject("Novar2BCMLib.Novar")

This is confusing to me. Within my COM object I thought it said the lib name was NOVAR2BCMLib.

library NOVAR2BCMLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");


[
uuid(4BFA500D-24D2-43EA-BC4D-8690A9BE0385),
helpstring("Novar Class")
]
coclass Novar
{
[default] interface INovar;
};
};

But within the registry I find it listed as Novar2BCM.Novar. Oh well, at any rate its working now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top