How to handle Error 442 in VBA?

brisidi

New Member
Joined
Dec 28, 2013
Messages
10
Hi everyone! I have prepared a VBA code that repeats a large number of times a structural analysis which is performed with the software Sap2000. It works perfectly well most of the time, however, sometimes the analysis suddenly stops with the message:

Error 442: Connection to type library or object library for remote process has been lost

I only have the option to "end" or click "help". When I click "end", the procedure does not stop and the message reappears immediately. I am starting to think that the error happens when Sap2000 is not active at the moment of being called, i.e. it is in the background. This happened once when Explorer was the active window (after 1 hour of successful running).

Does anyone have any idea how to deal with this? Is there any code I can add to keep Excel and Sap2000 linked during the analysis, even if I open other programs? I am using Excel 2010.

Thank you in advance!
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
That's not an easy thing to do.
Several low-level stuff happens behind the user, like Garbage Collection and memory management. Well, it might be possible that Sap2000 calls some GC routine when minimized or closed. It could be Windows trying to regain some RAM because it thought you won't need those objects created by Sap2000. It could also be some sort of limitation of VBA engine, or COM related.

If Sap2000 is an old software based on COM or something like that, there's a chance of COM unloading libraries to make room for other applications based in COM as well. I would suggest you to find out if that's the case.

To solve it, well, you might want to try a workaround like a loop to constantly call some kind of dummy function, like if I wanted to keep an Excel object alive, I keep asking it what's 1+1, or what version of Excel is it.
 
Upvote 0
Thank you very much for your answer TheXDS! It has been quite a long time since I posed the question (almost 2 years ago!), and I had already lost interest in it. Sap2000 is not an old software based on COM (at least that's what I think, I am not a professional in computer science and programming). The idea of the "dummy function" seems very attractive to me, I will definitely try it someday :).
 
Upvote 0
I will look forward for updates on that!
BTW, it is quite possible that it won't solve the issue, but doing that continous check will allow you to find out exacly moment when the issue occurs. I had a weird error 442 while using complex classes and several complicated MSForms controls that caused the disconnection of a Windows Forms library. It probably was because of memory constrains, or something like that... The solution was to use less controls and simplify the classes so VBA (or for that matter, COM) doesn't have to unload libraries to free up space.
 
Upvote 0

Forum statistics

Threads
1,221,525
Messages
6,160,329
Members
451,637
Latest member
hvp2262

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top