Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default shape range help

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default shape range help

Try changing...
Set network = Shapes("network")
Set shpRng = Shapes.Range(A)
shpRng.Group

-to-
Set network = ActiveSheet.Shapes("network")
Set shpRng = ActiveSheet.Shapes.Range(A)
shpRng.ReGroup
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



wrote in message
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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default shape range help

Thank you for your suggestion. Unfortunately, now

Set shpRng = ActiveSheet.Shapes.Range(A)

throws the dreaded run time error 1004

-semiopen

Jim Cone wrote:
Try changing...
Set network = Shapes("network")
Set shpRng = Shapes.Range(A)
shpRng.Group

-to-
Set network = ActiveSheet.Shapes("network")
Set shpRng = ActiveSheet.Shapes.Range(A)
shpRng.ReGroup
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



wrote in message
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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default shape range help

Are you sure that network is still a group?
Did you add "ActiveSheet." in front of ...
Shapes(costName).TextFrame.Characters.Text = newCost

Jim Cone
http://www.officeletter.com/blink/specialsort.html



wrote in message
Thank you for your suggestion. Unfortunately, now
Set shpRng = ActiveSheet.Shapes.Range(A)

throws the dreaded run time error 1004
-semiopen

Jim Cone wrote:
Try changing...
Set network = Shapes("network")
Set shpRng = Shapes.Range(A)
shpRng.Group

-to-
Set network = ActiveSheet.Shapes("network")
Set shpRng = ActiveSheet.Shapes.Range(A)
shpRng.ReGroup
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default shape range help


Jim Cone wrote:
Are you sure that network is still a group?
Did you add "ActiveSheet." in front of ...
Shapes(costName).TextFrame.Characters.Text = newCost


I didn't add the activesheet to *that* line - but that doesn't matter
since it is an implied parent object. After my sub dies - when I look
at Sheet1 (where this resides) - I see a whole bunch of ungrouped
shapes *with the cost changed to reflect the new cost*. When I step
through a test run with F8 - it is definitely the line I indicated that
Excel is balking at. Wierd.

Jim Cone
http://www.officeletter.com/blink/specialsort.html



wrote in message
Thank you for your suggestion. Unfortunately, now
Set shpRng = ActiveSheet.Shapes.Range(A)

throws the dreaded run time error 1004
-semiopen

Jim Cone wrote:
Try changing...
Set network = Shapes("network")
Set shpRng = Shapes.Range(A)
shpRng.Group

-to-
Set network = ActiveSheet.Shapes("network")
Set shpRng = ActiveSheet.Shapes.Range(A)
shpRng.ReGroup
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default shape range help

I have never heard of an "implied parent object", but if Excel is
accepting "Shapes" without specifying the sheet that it belongs
to, I certainly want to learn more.

To fix your problem, make the variant "A" a real array...
Dim A() as Variant.

Jim Cone
San Francisco, USA

wrote in message oups.com...

Jim Cone wrote:
Are you sure that network is still a group?
Did you add "ActiveSheet." in front of ...
Shapes(costName).TextFrame.Characters.Text = newCost


I didn't add the activesheet to *that* line - but that doesn't matter
since it is an implied parent object. After my sub dies - when I look
at Sheet1 (where this resides) - I see a whole bunch of ungrouped
shapes *with the cost changed to reflect the new cost*. When I step
through a test run with F8 - it is definitely the line I indicated that
Excel is balking at. Wierd.

Jim Cone
http://www.officeletter.com/blink/specialsort.html



wrote in message
Thank you for your suggestion. Unfortunately, now
Set shpRng = ActiveSheet.Shapes.Range(A)

throws the dreaded run time error 1004
-semiopen

Jim Cone wrote:
Try changing...
Set network = Shapes("network")
Set shpRng = Shapes.Range(A)
shpRng.Group

-to-
Set network = ActiveSheet.Shapes("network")
Set shpRng = ActiveSheet.Shapes.Range(A)
shpRng.ReGroup
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default shape range help

Well,

My original post was bone-headed in two ways:

1) My help files were there after all - just compressed or something
and I didn't need the CD to intall them :) This allowed me to realize
that ...

2) I should have been focusing on the Regroup method:

Sub changeCost(costName As String, newCost As Long)

Dim network As Shape
Dim i As Long, n As Long
Set network = ActiveSheet.Shapes("network")
network.Ungroup
ActiveSheet.Shapes(costName).TextFrame.Characters. Text = newCost
Set network = ActiveSheet.Shapes.Range(costName).Regroup
network.Name = "network"

End Sub

which works fine

The Regroup method saves me from the hassle of keeping track of the
original shapes.
Still, I'm sure that I'll sooner or later use the ( ) device to force
an evaluation that Nick and Peter discussed, so I'm glad I did it the
hard way first.

-semiopen

wrote:
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


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default shape range help

Well, yes, there that easy way of doing it....
Not sure how applicable all that variant and brackets stuff was, but at
least you are aware that things may not be as they seem sometimes.

NickHK

wrote in message
oups.com...
Well,

My original post was bone-headed in two ways:

1) My help files were there after all - just compressed or something
and I didn't need the CD to intall them :) This allowed me to realize
that ...

2) I should have been focusing on the Regroup method:

Sub changeCost(costName As String, newCost As Long)

Dim network As Shape
Dim i As Long, n As Long
Set network = ActiveSheet.Shapes("network")
network.Ungroup
ActiveSheet.Shapes(costName).TextFrame.Characters. Text = newCost
Set network = ActiveSheet.Shapes.Range(costName).Regroup
network.Name = "network"

End Sub

which works fine

The Regroup method saves me from the hassle of keeping track of the
original shapes.
Still, I'm sure that I'll sooner or later use the ( ) device to force
an evaluation that Nick and Peter discussed, so I'm glad I did it the
hard way first.

-semiopen

wrote:
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shape Range kuhrty Charts and Charting in Excel 3 April 22nd 10 05:12 PM
my curser changed from arrow shape to a cross shape???? bj New Users to Excel 1 February 5th 07 02:47 PM
Possible to select a range of cells from a Shape Object Gummy Excel Programming 1 May 11th 06 12:06 AM
Detecting if a range contains a shape Nick Hebb Excel Programming 3 October 28th 05 02:45 AM
align a picture/shape in a Range! Andoni[_18_] Excel Programming 1 August 22nd 04 06:11 PM


All times are GMT +1. The time now is 02:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"