title: Simple For Each through OLEObjects
body: <p>I just have a simple loop:</p>
  
  <pre><code>    Dim o As OLEObject
      For Each o In ActiveSheet.OLEObjects
          If InStr(1, o.Name, "abc") Then
              MsgBox o.Visible = False
          End If
      Next o
  </code></pre>
  
  <p>This should display names of my ActiveX buttons, but it doesn't. When I debug the program, For Each loop doesn't start ever once.</p>
  
  <p>I used <code>Workbooks("MyWorkbook.xlsm").Sheets(1).OLEObjects.Visible = False</code> and it works fine for my all buttons. Does anyone know why my loop doesn't works or how to set Visible property of buttons that name contains "abc"?</p>
  
  <p>I tried:</p>
  
  <pre><code>Option Explicit
  
      Private Sub Worksheet_SelectionChange(ByVal Target As Range)
          If Not Application.Intersect(Target, Range("B6:C20")) Is Nothing Or Not Application.Intersect(Target, Range("H6:H20")) Is Nothing Then
              'Me.OLEObjects.Visible = False &lt;-- This works fine
              Dim o As OLEObject
              For Each o In Me.OLEObjects
                  MsgBox o.Visible = False
              Next
          End If
      End Sub
  </code></pre>