S
semiopen
Greetings,
I just upgraded to Excel 2003 a few weeks ago - and the IT
department left out some VBA help files! It is going to be a couple of
days before I have time to wander over there, and in the mean time I'm
discovering that few books on Excel Programming say much about the
drawing layer. So...
I have a fairly large group of shapes grouped into a shape named
"network" , which consists of nodes, edges and costs on the edges. I
want to be able to change the cost displayed on certain edges (the
costs themselves are in text boxes). I gather from google that you have
to ungroup - change - regroup. I can ungroup and change no problem - it
is the regroup that is throwing me. Based on some code snippets I saw
on this group, I would think that the following should work, but it
throws an error:
Sub changeCost(costName As String, newCost As Long)
Dim shpRng As ShapeRange, network As Shape
Dim A As Variant
Dim i As Long, n As Long
Set network = Shapes("network")
n = network.GroupItems.Count
ReDim A(0 To n - 1)
For i = 1 To n
A(i - 1) = network.GroupItems(i).Name
Next i
network.Ungroup
Shapes(costName).TextFrame.Characters.Text = newCost
Set shpRng = Shapes.Range(A)
shpRng.Group
shpRng.Name = "network"
End Sub
+++++++++++++++++++
The line which causes problems is: Set shpRng = Shapes.Range(A)
What bozo-like programming error am I making? Any help would be
appreciated. Is there some sort of way to directly transfer the
groupitems to a shaperange?
Thanks for reading this
-semiopen
I just upgraded to Excel 2003 a few weeks ago - and the IT
department left out some VBA help files! It is going to be a couple of
days before I have time to wander over there, and in the mean time I'm
discovering that few books on Excel Programming say much about the
drawing layer. So...
I have a fairly large group of shapes grouped into a shape named
"network" , which consists of nodes, edges and costs on the edges. I
want to be able to change the cost displayed on certain edges (the
costs themselves are in text boxes). I gather from google that you have
to ungroup - change - regroup. I can ungroup and change no problem - it
is the regroup that is throwing me. Based on some code snippets I saw
on this group, I would think that the following should work, but it
throws an error:
Sub changeCost(costName As String, newCost As Long)
Dim shpRng As ShapeRange, network As Shape
Dim A As Variant
Dim i As Long, n As Long
Set network = Shapes("network")
n = network.GroupItems.Count
ReDim A(0 To n - 1)
For i = 1 To n
A(i - 1) = network.GroupItems(i).Name
Next i
network.Ungroup
Shapes(costName).TextFrame.Characters.Text = newCost
Set shpRng = Shapes.Range(A)
shpRng.Group
shpRng.Name = "network"
End Sub
+++++++++++++++++++
The line which causes problems is: Set shpRng = Shapes.Range(A)
What bozo-like programming error am I making? Any help would be
appreciated. Is there some sort of way to directly transfer the
groupitems to a shaperange?
Thanks for reading this
-semiopen