I am writing a VBA program to selectively group some rounded rectangle shapes. There are going to be sets of these groups, so I want to store them in an array. (For e.g. I would like to have dataSeriesGroup(1) to have a group of say three rounded rectangles, dataSeriesGroup(2) to have a group of three other rounded rectangles, and so on). I am trying to assign them to the group using the .Name attribute, as follows:
Dim ctr, ctr2, seriesCount, dataCount as Integer
Dim dataSeriesGroup() as Shape
Dim dataPoint() as Shape
Dim dTop, dLeft, dWidth, dHeight as long
Dim dataPointName as Variant
<Bunch of code to calculate values of dTop, dLeft, dWidth, dHeight, seriesCount, dataCount>
Redim dataSeriesGroup(seriesCount)
Redim dataPoint(dataCount, dataSeriesCount)
Redim dataPointName(dataCount)
For ctr = 1 to seriesCount
For ctr2 = 1 to dataCount
Set dataPoint(ctr2, ctr) = ActiveSheet.Shapes.AddShape(msoShapeRoundedRectangle, dLeft, dTop, dWidth, dHeight)
dataPointName(ctr2) = dataPoint(ctr2, ctr).Name
Next ctr2
Set dataSeriesGroup(ctr) = Activesheet.Shapes(Array(dataPointName)).Group
Next ctr
Everything is working fine, but when I am trying to set the dataSeriesGroup(ctr) I am getting an error "Run-time error '-2147352571 (80020005)': The item with the specified name wasn't found."
Can someone please provide some guidance as to what I am doing wrong?