title: VBA Excel, shape array. How to fix the Error "Index Into The Specified Collection Is Out Of Bounds"?
body: <p>In Excel I have three shapes namned <code>ON_1</code>, <code>ON_2</code> and <code>ON_3</code>.
  I am tring to  build an array of Shape indexes and get the ShapeRange.
  I have the VBA code but i get an error which says;
  The index into the specified collection is out of bounds. Here is the code:</p>
  
  <pre><code>Sub test()
  
  Dim sht As Worksheet
  Dim shprng As ShapeRange
  Dim shape_index As Variant
  Dim i As Long
  
  Set sht = ActiveSheet
  
  ReDim shape_index(1 To sht.Shapes.Count)
  For i = 1 To UBound(shape_index)
      shape_index(i) = i
  Next
  
  Set shprng = sht.Shapes.Range(shape_index)
  
  End Sub
  </code></pre>
  
  <p>I excpect to get variable <code>shprng</code> to include all the shapenames in the array.</p>
  
  <p>But instead I get an error with this line of code:</p>
  
  <pre><code>Set shprng = sht.Shapes.Range(shape_index)
  </code></pre>
  
  <blockquote>
    <p>Run-time error 1004: The index into the specified collection is out of bounds</p>
  </blockquote>
  
  <p>Any ideas?</p>