Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Adding Custom Shape

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Adding Custom Shape

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Adding Custom Shape

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
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
Adding custom list and text boxes to the custom tool bar from Excel C API Mousam Excel Discussion (Misc queries) 0 August 7th 07 09:19 AM
Adding custom list and text boxes to the custom tool bar from Excel C API Mousam Excel Programming 0 August 6th 07 10:05 AM
Adding a tip when the mouse is hovered over a shape in Excel.... [email protected] Excel Programming 6 August 3rd 06 09:53 PM
Adding a hyperlink to a shape Rand[_2_] Excel Programming 1 June 10th 06 01:02 AM
Programmatically adding buttons to a worksheet (Shape Object) Phil Excel Programming 3 January 26th 04 03:51 PM


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

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

About Us

"It's about Microsoft Excel"