Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel/VBA Automation Errors due to Office Service Pack 3.0 caused by Forms

After installing all latest windows updates my Excel VBA code is showing an automation error at the very start of the first module. It contains some forms as well as numerous modules of VBA code. However, when removing the forms (and associated code) everything is fine.

The same thing happened about a year ago after some other windows updates. Back then deleting the .exd files did the trick, but the current updates (including Service Pack 3) seem to be different.

What is going on and how can I get the forms to work? All the code is unchanged and has survived all previous windows/office updates. Running Windows 7 (same happening on Vista machine) and Office 2007.

like image 225
Rob Avatar asked Aug 15 '12 14:08

Rob


People also ask

How do I fix error 440 automation?

The best way to deal with the automation error is to use the “On Error Resume Next” statement that moves to the next line of the code irrespective of the error. You can also use the Err object to get information about the source and nature of the error.

How do I fix Runtime error 462?

To resolve this problem, modify the code so each call to an Excel object, method, or property is qualified with the appropriate object variable. The author of the post was getting the error because he was not using the Access object to open and close the database.

How do you fix catastrophic failure in Excel?

The solution though was pretty easy: Save the file as an "Excel Binary Workbook". Once you do that, the problem goes away for everyone using the workbook.


2 Answers

I used to see this a lot with Visual Basic and Crystal Reports; either due to a bad deployment or DLL Hell.

So, my guess is that it's not the code but perhaps some 3rd party controls (OCXs, DLLs) you're using.

Check your References (In VBA IDE, click Tools and References) and to see where each DLL is pointing.

See if any of the dates on the libraries are different than a working machine and you may find the culprit.


Edit

The OP found the problem by following the steps above.

The fix for this particular issue is to unregister mscomctl.ocx:

regsvr32 /u mscomctl.ocx 

Then register it:

regsvr32 mscomctl.ocx
like image 177
ray Avatar answered Oct 11 '22 12:10

ray


Same issue here, problem completely solved after registering mscomctl.ocx!

for Windows 7 or 2008 - remember to run cmd.exe "as administrator", and then:

for 32bit Windows systems: regsvr32 c:\windows\system32\mscomctl.ocx

for 64bit Windows systems: regsvr32 c:\windows\syswow64\mscomctl.ocx

like image 36
Micha Kaufman Avatar answered Oct 11 '22 12:10

Micha Kaufman