Hi,
I have a question about how to construct ShapeRange collection objects for dynamic shapes. I have a set of dynamically generated charts that I would like to group some of them together via VBA. This means that I need to construct a ShapeRange collection object dynamically. Unfortunately, the example provided by Microsoft only deals with static shapes, i.e., the number of shapes to be grouped and their names are known ahead of time. Below is the example from Microsoft:
----------------------------Microsoft Example--------------------------
The following example constructs a shape range that contains the shapes named "Big Star" and "Little Star" on myDocument and applies a gradient fill to them.
Set myDocument = Worksheets(1)
Set myRange = myDocument.Shapes.Range(Array("Big Star", "Little Star"))
myRange.Fill.PresetGradient _
msoGradientHorizontal, 1, msoGradientBrass
------------------------------End Example-----------------------------
The example above works for static shapes with predefined names. For dynamic shapes where their names are generated dynamically, one would think that replacing "Big Star", "Little Star" with a variable would do the trick, but it does not. For example the following code would generate an error message (shape not found):
Dim strShapeNames as string
Set myDocument = Worksheets(1)
strShapeNames="""Big Star"", ""Little Star"""
Set myRange = myDocument.Shapes.Range(Array(strShapeNames))
Does this mean it is not possible to group dynamically generated charts? Has anyone tried to construct ShapeRange objects for dynamically generated charts?
Thanks,
Tom