This workbook is currently referenced by another workbook and cannot be closed
<p>I am getting this error when closing an "add-in" workbook (.xla) using the Workbook.Close() method:</p>

<pre><code>error 1004:
"This workbook is currently referenced by another workbook and cannot be closed."
</code></pre>

<p>I closed every other workbook visible from the VBA Editor. Now the "add-in" workbook is the only open workbook, but I still get the error with ThisWorkbook.Close(). Resetting the project in the VBA editor with the "Stop button" did not help.</p>

<p>Why is Excel thinking that this workbook is currently referenced by another workbook ? (edit: there is no other workbook, I closed them all. At this point there is only one workbook open, and only one VBA project appearing in the VBA editor)</p>

<p>It seems somehow a reference has been leaked. Is there a way to avoid this bug ?</p>