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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

createobject function gives error! help!!!

Status
Not open for further replies.

tara8

Programmer
Nov 12, 2003
18
0
0
CA
I am getting this error:

"ActiveX component can't create object"

at this line of my code:

Set myObject = CreateObject("myProject.myClass", "myServerName")

(I've left out the real variable names).

Any ideas?

Also, my co-worker has the same code, only he's changed something in the object's interface and instead of getting the same error as me, he gets:

"Type mismatch"

HELP!
 
I also forgot to mention that this code works when I run it on my machine or my co-worker's machine, but it doesn't work on any application that is installed on any of our user's machines. It use to work before, but we've compiled a new application and it doesn't work now!
 
If the object's existing interfaces have been changed you need to do the following:

- Change the ActiveX project to no compatibility.
- Increment the version # and compile the ActiveX control. Don't overwrite the old version in its registered location.
- Set project compatibility to Binary, specifying the new ActiveX control file.
- Unregister the old version of the control with regsvr32.
- Replace the old version of the control with the new one.
- Register the new version with regsvr32.
- Check the application's project references now include the new version of the control.
- Recompile the application.

On end user's systems, make sure you unregister the old version of the control before replacing with and registering the new version.

Paul Bent
Northwind IT Systems
 
I'm pretty sure we've done all that. When we install, all old files get unregistered and removed, then replaced and registered again. But I'll see if we can try it again. I still don't get why it works on either of our machines, but not on our user machines and not when on our user machines but pointing to our machines as the server???
 
Here is what you need to do if it is a usercontrol project:

if running both projects in a group:

remove all forms that reference the components in the application project (not the component project)

set the Components 'compatibility' setting to project (or binary but project is the most reliable and since you are reinstalling/removing traces of the existing app- would be the way to go).

Close your project.
Reopen the project (make sure the compatibility setting is still in place)

recompile the project (make sure the compatibility setting is still in place, sometimes vb looses the reference)

In your application project, add a blank form.
drop on of your controls on the form. if the component project is a dll you will need to get the clsID and can skip this step. If component is a usercontrol, save the form and close the project.

Reopen the project.
Open the form with notepad and check the top few lines for the reference to your component. copy this entire line.


remove the scrap form from your project.
open all of the original forms that had bad references in notepad and replace the previous components information with your newly generated and copied CLSID, etc.

Add the forms through the ide and save your project.

This should take care of your problem if in fact your project is a usercontrol project. If it is a dll project, you can skip the temp form stuff and spelunk the registry to get the new clsid of the component and replace the entries in the forms.

Sounds a little crazy but i have had this happen before and it always fixes my issues. damn compatibility settings....

Ray H




 
Thanks VBDemiGod, I tried that, but that didn't do it. I'm not having problems in any code in the forms. I don't think I made my question clear...

I'm trying to instantiate a class module that was compiled into an ActiveX DLL and registered as a COM component. Whenever I try to do this at the line of code that uses the CreateObject() function I get the "ActiveX component can't create object" error message. The rest of the application works except for when I try to instantiate a certain class module that is new to the application. All other class modules are instantiated the same way, but for some reason a few new ones give me that error. We are using a 3-tiered application. I'm having problems accessing the 2nd tier from the 1st tier. And only for other machines than mine or my co-workers.

This one is really frustrating!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top