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!

Element not found when adding ActiveX Control to VBA Form

Status
Not open for further replies.

sa7ah

Programmer
Dec 7, 2001
4
GB
Hi,
I have an ActiveX control that is written in MS Visual Basic 6.0, and have made it into an .ocx file. I have previously added it to my VBA macro in MS Word 2000 and it has worked perfectly. Then, after a few months, for some reason whenever I try and run or open the MS Word Document I get a memory error and Word crashes. So I then have to remove the ActiveX Control from the form to stop Word from crashing. When I try to add the ActiveX control again I receive an "Element not found" error. There is no help available.

This is the second time this has happened. The first time I fixed it by deleting the .ocx file and removing the relevant bits from the registry. I then make the ActiveX control again and it works fine for a few months.

Now, the same thing has happened and I have tried to fix it by using the previous "solution". But this does not work.

Has this ever happened to anyone else before? If so, do you have any helpful solutions and explanations as to why this happens.

 
HI..I'am sorry i dont have the solution for you.

I am having the exact same problem...each time i drop my ocx file onto th VBA form i get "element not found" error..

i was wondering if you ever found the solution to this problem ??
 
Hi,

I did find a solution - not a very good one though.

When this first happened to me I was able to delete all references to the OCX file in the registry and then re-compile the activex component and then add it to the form.

If you have already tried this and it didn't work then I worked around it by creating a new activex control and copying and pasting the code (and everything else) in to the new project and naming it something different.

It is not the best solution but it worked for me. I am still concerned why the activex control suddenly becomes unrecongised.
 
Wow..that was a quick response..Thanks..

I havent tried the first approach and frankly a bit
hesitant to mess with the registry since this
is my first attempt to modify it.
Any suggestions on how to go about deleting all
references to the OCX file in registry???

 
Hi,

When you open up the registry you can use the "find" command - it is under the edit menu. I found and deleted all keys that contained ImageX (my ocx was called ImageX.ocx) and ImageExport (the control was called ImageExport.ctl). Don't forget to delete the control from the form first, then delete the actual ocx files, and then delete the references in the registry.

Next time you compile your control you should set the version compatability to project compatability within the project properties under the component tab. There is a full explanation about version compatability on the Microsoft website - I would give you the URL but I can't find it at the moment!! You will only be able to set the compatability if you created the ActiveX component on your machine.

Hope this helps!
 
Try going to your profiles directory:
On NT, it is: \WinNT\Profiles\userXXX\ApplicationData\Microsoft\Forms\.
On W2K, it starts from "Documents and settings".

Delete the .box file for your application and perhaps a .exd file for your control.

Hope this helps.
 
Oh my, you cannot imagine how much I appreciate that post!

I have been banging my head against this particular brick wall for a long time and could NOT find a solution. I found this site and post via Google and I had to register just to say THANK YOU! I tried your solution and it worked beautifully.

Think I'll be sticking around here for a while!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top