title: Runtime Error '459': Object or class does not support the set of events
body: <p>i have created a simple class named <strong>Class1</strong> and was testing if events are available for the objects or containers listed with WithEvents.</p>
  
  <p><a href="https://i.stack.imgur.com/P75bJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P75bJ.png" alt="Class1"></a></p>
  
  <p><strong>Class1</strong>:</p>
  
  <pre><code>Option Explicit
  
  Public WithEvents Obj As OLEObject
  
  Private Sub Obj_GotFocus()
      MsgBox "Got U"
  End Sub
  
  Private Sub Obj_LostFocus()
      MsgBox "Lost U"
  End Sub
  </code></pre>
  
  <p>As i understand, <strong>OleObject</strong> is a <strong>container</strong> and such it has the above 2 events listed for it.</p>
  
  <p>In <strong>Module1</strong>, this is a simple code which sets a single OleObject on <strong>Sheet1</strong> of my workbook. For testing purpose, I have added <strong>5 different ActiveX controls</strong> to see which one gets the events.</p>
  
  <p><strong>Module1</strong>:</p>
  
  <pre><code>Option Explicit
  
  Dim clsObj As Class1
  
  Sub doit()
      Set clsObj = New Class1
      Set clsObj.Obj = Sheet1.OLEObjects(1) ' Getting error 459 on this line
  End Sub
  </code></pre>
  
  <p>The following line above results in an error:</p>
  
  <blockquote>
    <p>Runtime Error '459':
    Object or class does not support the set of events</p>
  </blockquote>
  
  <p><strong>Note</strong>:</p>
  
  <blockquote>
    <p>I can add a WithEvents to the object within this container e.g.
    a <strong>Label1</strong> and get it to work, but it gives a different set of
    events and not the Got_Focus() &amp; Lost_Focus() events. However, this is not what i want :</p>
  </blockquote>
  
  <p><strong>Class1</strong>:</p>
  
  <p><a href="https://i.stack.imgur.com/CRvPe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CRvPe.png" alt="MSForms.Label"></a></p>
  
  <p><strong>Module1</strong>:</p>
  
  <p><a href="https://i.stack.imgur.com/K442l.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K442l.png" alt="Module1"></a></p>
  
  <p><strong>Questions</strong>:</p>
  
  <ol>
  <li>Can anyone explain why code does not allow to set the OleObject
  container object?</li>
  <li>What is the logic or purpose behind making these events available
  when they cannot be triggered at all?</li>
  <li>Why is the error message informing that these events are not
  available for any of the ActiveX controls added to Sheet1?</li>
  <li>Is there an alternative way to access the 2 OleObject container
  events?</li>
  </ol>