R
Ron West
I have been given a spreadsheet to fix, that worked fine using XL2000 but
runs out of memory halfway through when run using XL2007 SP1.
It has to create about 700 different account spreadsheets based on a single
template.
For each iteration, the template workbook is loaded and set to be a local
object wbOutput. It is then saved as the appropriate account name using
wbOutput.SaveAs; next, the different dataranges within are given their
values, etc, then wbOutput is re-saved and closed using wbOutput.Save
followed by wbOutput.Close.
wbOutput is only set to Nothing at the end of the procedure after all the
iterations, as that was sufficient in XL2000.
Using the GetProcessMemoryInfo() API, I have worked out that each time the
wbOutput.SaveAs method is executed, it grabs about 3Mb extra - but
wbOutput.Close does not release the memory as it did in XL2000 - so once
XL2007 gets to about the 500th iteration it crashes with insufficient memory.
I'm going to try setting wbOutput to Nothing in each iteration, to see if
that helps - but I still think this is a bug in XL2007 SP1 that needs fixing,
so if any MVP agrees with me and can report it to the appropriate place, I'd
appreciate it.
runs out of memory halfway through when run using XL2007 SP1.
It has to create about 700 different account spreadsheets based on a single
template.
For each iteration, the template workbook is loaded and set to be a local
object wbOutput. It is then saved as the appropriate account name using
wbOutput.SaveAs; next, the different dataranges within are given their
values, etc, then wbOutput is re-saved and closed using wbOutput.Save
followed by wbOutput.Close.
wbOutput is only set to Nothing at the end of the procedure after all the
iterations, as that was sufficient in XL2000.
Using the GetProcessMemoryInfo() API, I have worked out that each time the
wbOutput.SaveAs method is executed, it grabs about 3Mb extra - but
wbOutput.Close does not release the memory as it did in XL2000 - so once
XL2007 gets to about the 500th iteration it crashes with insufficient memory.
I'm going to try setting wbOutput to Nothing in each iteration, to see if
that helps - but I still think this is a bug in XL2007 SP1 that needs fixing,
so if any MVP agrees with me and can report it to the appropriate place, I'd
appreciate it.