Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default Grouping Shapes in 2007

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Grouping Shapes in 2007

This is a bit cleaner

for testing group a shape(diamond) a line, a textbox named Customdmd,
Customlin & Customtxt respectively and name the group Customgrp

Sub test()
Dim i As Long
Dim iDur2 As Double
Dim sID As String
Dim ws As Worksheet

Set ws = ActiveSheet

For i = 1 To 5
sID = Right$("0" & i, 2)
iDur2 = 50

With ws
With .Shapes("Customgrp").Duplicate
.Ungroup
End With

Call NewName(ws, "Customdmd", "dmd" & sID)
Call NewName(ws, "Customlin", "lin" & sID)
Call NewName(ws, "Customtxt", "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 = (i - 1) * 100
End With
Next

End Sub

Function NewName(ws As Worksheet, sName As String, sNewName As String) As
Long
Dim i
With ws.Shapes
For i = .Count To 1 Step -1
If .Item(i).Name = sName Then
.Item(i).Name = sNewName
Exit For
End If
Next
End With
End Function

Peter T


"Peter T" <peter_t@discussions wrote in message
...
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





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default Grouping Shapes in 2007

Peter T,

It works like a champ in 2003, even cut down the file size a lttle bit. I'm
going to forward it to my colleague who has 2007 to see if it works.

Thanks a lot for your help
--
Brian


"Peter T" wrote:

This is a bit cleaner

for testing group a shape(diamond) a line, a textbox named Customdmd,
Customlin & Customtxt respectively and name the group Customgrp

Sub test()
Dim i As Long
Dim iDur2 As Double
Dim sID As String
Dim ws As Worksheet

Set ws = ActiveSheet

For i = 1 To 5
sID = Right$("0" & i, 2)
iDur2 = 50

With ws
With .Shapes("Customgrp").Duplicate
.Ungroup
End With

Call NewName(ws, "Customdmd", "dmd" & sID)
Call NewName(ws, "Customlin", "lin" & sID)
Call NewName(ws, "Customtxt", "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 = (i - 1) * 100
End With
Next

End Sub

Function NewName(ws As Worksheet, sName As String, sNewName As String) As
Long
Dim i
With ws.Shapes
For i = .Count To 1 Step -1
If .Item(i).Name = sName Then
.Item(i).Name = sNewName
Exit For
End If
Next
End With
End Function

Peter T


"Peter T" <peter_t@discussions wrote in message
...
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






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
Shapes on 2007 Spreadsheets BillCPA Excel Discussion (Misc queries) 5 March 12th 09 09:21 PM
How can I use Shapes in 2007? nkat Excel Programming 3 November 10th 08 01:27 PM
Shapes in 2007 from 2003 WayneR Excel Discussion (Misc queries) 0 May 23rd 08 08:16 PM
PROB: Grouping Shapes With An Array Loop Boicie Excel Programming 2 January 14th 04 08:21 PM
Grouping Shapes MatP Excel Programming 1 November 20th 03 07:12 PM


All times are GMT +1. The time now is 11:10 PM.

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"