How to correct a 'fails to instantiate control'

L

lfriday

I create hundreds of similar documents using vba and a template that contains
3 combo boxes. In some files, the combo boxes appear to get corrupted,
evidenced by the bad file(s) opening in design mode. I finally got a message
inidicating a failure to instantiate control. Any help in understanding how
it occurs and/or how to repair or how to test or identify programmatically
would be appreciated.
 
P

Pesach Shelnitz

Hi,

I suspect that the VBA code in your template is not doing much to dispose of
unneeded objects and free up memory (to promote garbage collection). For
example, when your code is finished using an object that it creates by Dim
and Set statements, you should add the following line (in which myObject
should be changed to the actual name of your object) at the end of every Sub
for each object created in your VBA code.

Set myObject = Nothing

Of course, without seeing your code, it is difficult to be sure what the
problem is.
 
Top