PC Review


Reply
Thread Tools Rate Thread

Adding Custom Shape

 
 
J Streger
Guest
Posts: n/a
 
      10th Apr 2008
I have created a custom shape on my sheet to use as a template. In the code I
use the following to copy the shape and rename it:

'Copy bar
oColorBar.Copy

'Paste to Cell
Me.Paste Destination:=rColorCell

'Rename
Me.Shapes(Me.Shapes.Count).name = cTPM & "_" & rCell.Row

Now this works fine in Excel 2003 or before. I tested this in Excel 2007 and
this fails, as it seems the shapes collection is now sorted and the new shape
is not necessarilty added to the bottom of the collection. So I still want to
copy my tempalte shape to the sheet and get a handle on it, but I don't know
it's index in the shapes collection, and it's name is some default name with
a number after it.

I essentially want to do a set myShape = Shapes.add(customShape). Any ideas?

--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

User of MS Office 2003

 
Reply With Quote
 
 
 
 
Jim Cone
Guest
Posts: n/a
 
      10th Apr 2008
This works in pre xl2007 versions...
'--
Sub PutErThere()
Dim shp As Shape
Set shp = Me.Shapes("oColorBar").Duplicate
With Me.Range("oColorCell")
shp.Top = .Top
shp.Left = .Left
End With
shp.Name = "Mush"
Set shp = Nothing
End Sub
'--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"J Streger"
wrote in message
I have created a custom shape on my sheet to use as a template. In the code I
use the following to copy the shape and rename it:

'Copy bar
oColorBar.Copy

'Paste to Cell
Me.Paste Destination:=rColorCell

'Rename
Me.Shapes(Me.Shapes.Count).name = cTPM & "_" & rCell.Row

Now this works fine in Excel 2003 or before. I tested this in Excel 2007 and
this fails, as it seems the shapes collection is now sorted and the new shape
is not necessarilty added to the bottom of the collection. So I still want to
copy my tempalte shape to the sheet and get a handle on it, but I don't know
it's index in the shapes collection, and it's name is some default name with
a number after it.

I essentially want to do a set myShape = Shapes.add(customShape). Any ideas?

--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

User of MS Office 2003

 
Reply With Quote
 
J Streger
Guest
Posts: n/a
 
      10th Apr 2008
thank you greatly Never even knew that function existed. Much nicer than
copy/paste.
--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

User of MS Office 2003



"Jim Cone" wrote:

> This works in pre xl2007 versions...
> '--
> Sub PutErThere()
> Dim shp As Shape
> Set shp = Me.Shapes("oColorBar").Duplicate
> With Me.Range("oColorCell")
> shp.Top = .Top
> shp.Left = .Left
> End With
> shp.Name = "Mush"
> Set shp = Nothing
> End Sub
> '--
> Jim Cone
> San Francisco, USA
> http://www.realezsites.com/bus/primitivesoftware
> (Excel Add-ins / Excel Programming)
>
>
>
> "J Streger"
> wrote in message
> I have created a custom shape on my sheet to use as a template. In the code I
> use the following to copy the shape and rename it:
>
> 'Copy bar
> oColorBar.Copy
>
> 'Paste to Cell
> Me.Paste Destination:=rColorCell
>
> 'Rename
> Me.Shapes(Me.Shapes.Count).name = cTPM & "_" & rCell.Row
>
> Now this works fine in Excel 2003 or before. I tested this in Excel 2007 and
> this fails, as it seems the shapes collection is now sorted and the new shape
> is not necessarilty added to the bottom of the collection. So I still want to
> copy my tempalte shape to the sheet and get a handle on it, but I don't know
> it's index in the shapes collection, and it's name is some default name with
> a number after it.
>
> I essentially want to do a set myShape = Shapes.add(customShape). Any ideas?
>
> --
> *********************
> J Streger
> MS Office Master 2000 ed.
> MS Project White Belt 2003
>
> User of MS Office 2003
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shape and custom layout shape Beautiful Piotr Microsoft Powerpoint 3 17th Feb 2010 05:01 PM
PowerPoint events for adding a shape, deleting a shape and slide Mark Kestenbaum Microsoft Powerpoint 1 3rd Jan 2008 12:04 AM
Adding a hyperlink to a shape Rand Microsoft Excel Programming 1 10th Jun 2006 01:02 AM
adding drop-shadows to a form with a custom shape? Chris Barnard Microsoft VB .NET 0 16th Dec 2004 01:05 PM
Form with custom shape Giox Microsoft C# .NET 4 13th Oct 2004 01:35 PM


Features
 

Advertising
 

Newsgroups
 


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