title: Excel crashing on repeatedly opening and closing workbooks
body: <p>In Excel2003 I'm seeing a strange thing happening with a macro I wrote to automatically modify a list of workbooks. I've got a list of 12000 workbooks to modify,so I need to open each one in turn, do stuff inside and then save and close.
  After about 1000 workbooks have been processed (sometimes a few hundred more), Excel just crashes.</p>
  
  <p>Here is pseudo-code for what I am doing</p>
  
  <pre><code>public sub ProcessWorkbooks()
  
      dim i as Integer
      dim targetWorkbook as Workbook
  
      With thisWorkbook.Sheets("Main").Range("A15")
          Do While .Offset(i, 0).Value &lt;&gt; ""
              set targetWorkbook = Application.Workbooks.Open(.Offset(i, 3).Value)
              If targetWorkbook Is Nothing Then
                  Goto NextIteration
              End If
              Application.ScreenUpdating = False
              Call ProcessWorkbook(targetWorkbook)
              Call targetWorkbook.Save
              DoEvents
              Call targetWorkbook.Close
              Application.ScreenUpdating = True
  NextIteration:
              i = i + 1
          Loop
      End With
  
  end sub
  </code></pre>
  
  <p>My first thought was a memory leak, but then I think Excel should become really slow before crashing, but the execution speed stays the same right up to the crash (I haven't sat there and looked at it for several thousand workbooks though...).
  Is there something in Excel itself that can cause this kind of crash to happen? Maybe the history needs clearing out or something like that?
  Has anybody had this happen before?</p>