I had made an Excel macro using some ActiveX control buttons. It runs perfectly on my old PC. Some days back I purchased a new PC and when I compiled it reflect following error:-
"Object Library invalid or contains references to objects definitions that could not be found."
Also when I run this macro in design mode through the ActiveX button, it creates a sample blank module by a new default name corresponding to that button.
I tried everything that is available on the web. I even removed .exd files, checked my .ocx files. etc.
Now I am clueless about what to do as same macro is running perfectly on my colleagues laptop and they also have same version of Excel even.
Screenshot of the error that I am getting when compiling the code.
Related
I am using IBM Pcom 64bits and micro office 64bits, and I would like to use VBA to interact with Pcom.
I created an Excel file with VBA, however, there is an error "automation error, The specified module could not be found" when execute this:
Set autECLSession = CreateObject("PCOMM.autECLSession")
And the weird thing is that, if I put this Excel to my "Desktop", it works! For other locations, it will always "automation error, The specified module could not be found".
I would like to make this Excel with VBA works everywhere, any idea what happens?
I have a great Monte Carlo simulation macro for MS Project that I use all of the time. Since I upgraded my version of MS Office, it no longer works.
I got the macro from the following link: https://sourceforge.net/projects/montecarloprj/?source=typ_redirect
It generates an error (Compile error: User-defined type not defined) at the following line:
Sub SetupExcel(ByRef XlApp As Excel.Application, ByRef XlBook As Excel.Workbook)
Previously, to resolve this issue I needed to enable "Microsoft Excel 12.0 Object Library" in Tools-References in VBA. However, that option (or any Excel Object Library) is not available.
If you can't find the object library on the list, you can use the Browse button to add it to the list yourself. Find out where the excel.exe file is located and use the Browse... button in the References dialog box. Be sure to change the file type to Executable Files when adding the reference (lower-right corner of the Add Reference dialog box).
I have an Excel VBA Project which included a custom class module. I changed the code to remove all references to this class, then removed the class module after exporting it. The program then had a compile error
user type not defined
I re-imported the custom class and the program compiled normally. I deleted all code and comments from the custom class module, leaving it as a blank module, and the program still compiled OK. Again, after removing the custom class I get the "user type not defined" error.
No offending code line is highlighted at any of the above steps.
Any ideas?
The problem was experienced using Excel 2016.
The problem was solved by opening the file in Excel 2007, which I fortunately retained before installing Office 365. In Excel 2007 I was able to remove the now empty class module and re-compile and save. On re-opening in Excel 2016, the project again compiled just fine.
I repeated the process on another backup copy with both Excel 2007 and 2016 and the problem consistently occurs with Excel 2016 but not with Excel 2007.
Thanks for other's comments.
I had a similar problem with the same message "user type not defined" running Excel 2007.
The problem arose when I was updating the code in a class module and removed an old private user-defined type and all references to it. This then raised the compiler error "user type not defined".
My temporary solution was (for this description let the type name be "TName"):
Remove "TName" and all references to it from the class module.
Create a new empty class module and name it "TName".
Recompiled and save the project.
Remove the newly created class module "TName".
Recompiled and save the project.
Exit all instances of Excel.
Restart excel with the project.
Done.
Note!
This removes the compiler error "user type not defined" for the moment. However, if any other error appears and it has not even have to be related to the "user type not defined" issue. The error "user type not defined" reappears. So, this is a description to remove the error for the moment. But if further development is done, it is most likely that the error will reappear and if it is not documented thoroughly it will be even harder to fix, since then you probably have forgotten the type name that originally caused the error!
This is a rough description of what I have done. However, I thought I would contribute my work here and let the next person come up with a better solution and description.
I am working on a macro-heavy Excel file with many ActiveX controls. All functions of the file work perfectly on my PC and another, but I get the error 32809 when the Auto_Open macro tries to activate a sheet on other PCs.
I know this problem has been posted many other times on many different forums, but none of the solutions I have found that worked for others have worked for me. I have tried all of the following possible solutions:
Deleting all *.exd files from both the Temp\Excel8.0 and Temp\VBA
Disabling all ActiveX controls
Opening the file on the PC that does not work and saving with a different name
Modifying the code slightly, recompiling and saving
Deleting all ActiveX controls and re-creating them on a PC that did not work
The only thing that stopped the 32809 error from occurring was deleting all of the ActiveX controls, but if I save the now functioning file on my PC and try to open it on the one that did not work the error comes back.
While deleting all of the controls did stop the error, it is extremely inconvenient to have to recreate all of the controls on a different PC when I make an update to the file. I am open to just about any suggestion that might help with this extremely frustrating problem.
I ended up deleting all of the ActiveX controls from all of the sheets before saving any changes and writing a routine to run on opening the file to re-create all of the necessary controls and re-save the file with the controls the first time it is opened on any given PC.
Creating the controls doesn't allow debugging until after all routines have completed, so I used the Application.OnTime command rather than simply calling the next routine to work around this.
Hope this can help. I have been dealing with famous runtime error 32809 for a while. in the VBA, if some object is not defined, the runtime error 32809 will prompt up when the Excel VBA runs. but now, more cases about this runtime error is not caused by "undefined objects ...", it's caused by the Microsoft security patch problems. the patch makes the VBA ActiveX controls are not recognizable, so VBA treats these valid ActiveX controls as undefined objects. To resolve the issue, Microsoft released new patches to fix the early issue.
if you ensure the existing VBA has no "defined object" or it used to work well, you can upgrade your Microsoft patch. the latest version for Excel 2010 should be 14.0.7177.5000 or later.
Suggestion: don't include ActiveX controls in VBA if the product is used by a variety of users. this can cause the endless problem. any windows updates can likely impact the VBA.
I have an Excel 2010 file (.xlsm) that contains code in a few modules including ThisWorkbook. The ThisWorkbook module contains a few Event procedures, including a _SheetActivate event.
I have a button on one sheet that, when clicked, activates a different sheet.
Today after working on some code in one of the regular modules, I clicked the button and got a
Run time error '-2147417848 (80010108)'
Method 'Activate' of object '_Worksheet' failed.
Any attempt to activate a different sheet (manually or programmatically) crashes the Application.
After some extensive research, all I found was this page which gives further information regarding the error:
-2147417848 (80010108): The object invoked has disconnected from its clients.
Resolving the error isn't so much of a concern to me because I don't need that particular event anymore. However, I do need to figure out why Excel keeps crashing. I tried to delete the code, but Excel crashed. So I tried commenting the code out, but Excel still crashed. Alas, everything I've tried has resulted in a crash. This leads me to believe that something must be corrupt in the script within that module (the code in other modules seems to work fine, but none of the other procedures activate a sheet).
I've read that an option would be to copy everything (including code) over to a new workbook, but I'd like to avoid that if possible as that would require copying more than the current sheet...but I can't copy the other sheets without Excel crashing. Does anyone have any ideas on how I could remove/delete the code from ThisWorkbook?
After too many crashes to count, I was finally able to resolve the issue.
First I copied the code (Ctrl + C) from ThisWorkbook that I wanted to be able to use later and pasted it into a blank notebook file. Then I did as Patrick suggested and exported the regular modules.
At this point, I tried programmatically removing the code, but Excel crashed again. Then it dawned on me that I didn't have to delete the code manually or programmatically; I just saved the file as an .xlsx document which by design removes the code.
From there I closed the file, opened it back up, and imported the .bas files I'd exported earlier. The last step before I saved the file in .xlsm format was to paste the copied code from the first step back into ThisWorkbook.
Everything works like a charm now. Thanks for the help! Cheers!