title: How do I group a set of shapes programmatically in excel 2007 vba?
body: <p>I am iterating over data on the Electrical Tables sheet and creating shapes on a Shape sheet. Once the shapes are created I would like to programmatically group them. However I can't figure out the right syntax. The shapes are there, selected, and if I click the group button, they group perfectly. However with the following code I get </p>
  
  <blockquote>
    <p>Runtime Error 438 Object does not support this method or property.</p>
  </blockquote>
  
  <p>I am basing this code on VBA examples off the web - I am not a strong VBA programmer. What is the right way to do this? I am working with excel 2007 and switching excel versions isn't an option.</p>
  
  <p><strong>Problematic snippet:</strong> </p>
  
  <pre><code>Set shapeSheet = Worksheets("Shapes")
  
  With shapeSheet
      Selection.ShapeRange.Group.Select
  End With
  </code></pre>
  
  <p><strong>Context:</strong></p>
  
  <pre><code>Dim shapeSheet As Worksheet
  Dim tableSheet As Worksheet
  Dim shpGroup As Shape
  
  Set shapeSheet = Worksheets("Shapes")
  Set tableSheet = Worksheets("Electrical Tables")
  
  
  With tableSheet
      For Each oRow In Selection.Rows
              rowCount = rowCount + 1
              Set box1 = shapeSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, 50, 50 + ((rowCount - 1) * 14), 115, 14)
              box1.Select (False)
              Set box1Frame = box1.TextFrame
              Set box2 = shapeSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, 165, 50 + ((rowCount - 1) * 14), 40, 14)
              box2.Select (False)
              Set box2Frame = box2.TextFrame
       Next
  End With
  
  Set shapeSheet = Worksheets("Shapes")
  
  With shapeSheet
      Selection.ShapeRange.Group.Select
  End With
  </code></pre>