views:

282

answers:

3

Is there a way to force garbage collection in VBA/Excel 2000?

This question refers to the Macro language in Excel. Not using VB .NET to manipulate Excel. So GC.collect() won't work

A: 

Not that i know of. What code do you require to do so?

astander
+5  A: 

You cannot take advantage of garbage collection provided by the .NET Framework when using straight VBA. Perhaps this article by Eric Lippert will be helpful

RandomNoob
I did not know that VBA used reference counting and didn't support clean up of circular references. That might be the underlaying problem. The original problem was that sometimes workbooks didn't close correctly when closed and de-referenced in class destructors. I thought the problem came from that the object hadn't been collected yet. Most likely I have a circular reference some wheyer that come into play some times. Thanks for the tip.
Zen
A: 

VBA/Excel does not have garbage collection, like old VB. Instead of GC, it uses reference counting. Memory is freed when you set a pointer to nothing (or when variable goes out of scope). Like in old VB it means that circular references are never freed.

yu_sha