Textstream object remains open in Excel after being closed by VBA
<p>I have some VBA code in Excel 2007 which creates, fills, then closes a Textstream file object (abbreviated snippet below).</p>

<pre><code>Set CSV = FSO.CreateTextFile(strPathOut &amp; Application.PathSeparator &amp; strFileOut)

'Fill the file

CSV.Close
</code></pre>

<p>The code works perfectly, including the <code>CSV.Close</code> instruction, however if I then try to delete or modify the file (e.g. in Windows Explorer or Notepad) the system claims Excel still has the file open.  Seemingly the only way to release it is to close Excel itself.</p>

<p>I've checked that <code>CSV.Close</code> is doing what it's supposed to from the VBA side; it's not causing a runtime error, and certainly the file is no longer available to be written to after that instruction.</p>

<p>My project is early bound to the Microsoft Scripting Runtime, scrrun.dll.  I've tried removing that reference but I get the same result.</p>

<p>This is not a showstopper for the project, but it's a PITA during development.  Anybody know what's going on?</p>