Thread: name a picture
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] john.opie@gmail.com is offline
external usenet poster
 
Posts: 7
Default name a picture

Hi -

You don't necessarily give the chart a name, but rather the shape that
the chart is embedded in.

I won't dupe all the code he however, once you have copied it to the
clipboard as a picture you can give it a name as you paste it via the
following:

With Workbooks("YourWorkbookNameHere").Activate
With .Sheets("YourWorkSheetHere")
.Cells("YourCellsHere").Select
.Pictures.Paste.Select
Selection.ShapeRange.Parent.Name =
"YourChartNameHere"
End With
End With

Where (obviously) you replace the "YourWorkbookNameHere",
"YourWorkSheetHere" and "YourCellsHere" and "YourChartNameHere" with
your own references.

It took a while to figure out that you don't give the chart a name at
any point, but rather you assign a name to the (object) parent of the
picture, which is a shape. You can then access the shape at any given
point later on when it is given a sensible name.

John