View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Grouping Shapes in 2007

This is ridiculous but try this

With ActiveSheet
With .Shapes("Customgrp").Duplicate
.Ungroup
End With
.Shapes("Customdmd").Name = "tmpName"
.Shapes("Customdmd").Name = "dmd" & sID
.Shapes("tmpName").Name = "Customdmd"

.Shapes("Customlin").Name = "tmpName"
.Shapes("Customlin").Name = "lin" & sID
.Shapes("tmpName").Name = "Customlin"

.Shapes("Customtxt").Name = "tmpName"
.Shapes("Customtxt").Name = "txt" & sID
.Shapes("tmpName").Name = "Customtxt"

.Shapes("txt" & sID).TextFrame.Characters.Text = ""
.Shapes("lin" & sID).Width = iDur2 * 1.168 - 5
With .Shapes.Range(Array("lin" & sID, "dmd" & sID, "txt" & sID)).Group
.Name = "grp" & sID
End With
.Shapes("grp" & sID).Visible = True
.Shapes("grp" & sID).Left = lLeft
End With

Obviously you'll adapt to your original to cater for pre Excel 2007

Regards,
Peter T


"Brian" wrote in message
...
I created the following code in Excel 2003 and it works fine.
With Worksheets("Chart")
With .Shapes("Customgrp").Duplicate
.Ungroup
End With
.Shapes("Customdmd").Name = "dmd" & sID
.Shapes("Customlin").Name = "lin" & sID
.Shapes("Customtxt").Name = "txt" & sID
.Shapes("txt" & sID).TextFrame.Characters.Text = ""
.Shapes("lin" & sID).Width = iDur2 * 1.168 - 5
With .Shapes.Range(Array("lin" & sID, "dmd" & sID,
"txt"
& sID)).Group
.Name = "grp" & sID
End With
.Shapes("grp" & sID).Visible = True
.Shapes("grp" & sID).Left = lLeft
End With
When I run it in 2007, I get "Error 1004 Group has been disable for
Object,"
for the With .Shapes.Range(...) Statement, or something like that. What's
the correct way to group shapes in excel 2007. I don't want to have to
select the object either. Also big picture, what I'm doing is I have a
custom shape that consists of a line a diamond and a text box, I need to
duplicate the custom shape, put something in the text box, and adjust the
width of the line, then put those three shapes back together, name the
group,
and then place the group at a particular horizontal location on the
spreadhsheet. So if there's a better way to do it then let me know

Thanks in advance for your help
--
Brian