title: What causes Visual Basic Run-time error -2147319765 (8002802b) in Excel when an ActiveX control has been instanced?
body: <p>I have created an ActiveX control using C++.  I use Visual Basic code to instance the control in an Excel worksheet.  I can only run the VB script once, subsequent runs cause the following runtime error when attempting to access the 'ActiveSheet' variable:</p>
  
  <pre><code>Microsoft Visual Basic
  
  Run-time error '-2147319765 (8002802b)':
  
  Automation error
  Element not found
  </code></pre>
  
  <p>I am trying to work out what causes this error and how I can fix it?</p>
  
  <p>As an experiment I tried creating a simple ActiveX control generated by Visual Studio wizards (in both VS 2005 &amp; 2008).  I didn't add or modify any code in this test case.  The simple test case still causes this error.</p>
  
  <p>Other ActiveX controls in the system don't cause this error (eg I tried instancing 'Bitmap Image') from VB code.</p>
  
  <p>This is the VB code (a macro that I recorded, but hand-coded VB has the same issue):</p>
  
  <pre><code>Sub Macro1()
      ActiveSheet.OLEObjects.Add(ClassType:="test.test_control.1" _
          , Link:=False, DisplayAsIcon:=False).Select
  End Sub
  </code></pre>
  
  <p>Can anyone give me an answer on this?  Alternatively any pointers to resources that may help will be appreciated.</p>
  
  <p>Thanks</p>