Chart object number

T

Tom

I have a number of charts in my worksheet that I would like to copy to a word
document. I am thinking the best way is to:

1. select the chart object
2. copy it
3. Tthen open a Word doc (not sure about the code for this)
4. paste it in the word doc

How can I get the chart object number to select the chart? for example if I
have 200 charts they are not always numbered sequentially from 1-200
depending on how many times the charts are created. I may have a chart 299,
then a chart 333. How do I go the chart object number to be able to
reference it and select the chart.
 
J

Jon Peltier

You could manually or programmatically rename the chart objects
(http://peltiertech.com/Excel/ChartsHowTo/NameAChart.html). If the charts
are created programmatically, this naming can be integrated into the code.

Or if you know where the charts are in the sheet, you can loop through the
chart objects to find the one whose .TopLeftCell is a particular cell.

- Jon
 
T

Tom

Jon,

Thanks. I will try to programmatically rename them. Is there a way to
determine the index number for each chart and then use that?

Thanks
Tom
 
J

Jon Peltier

If you don't care which ones are accessed in which order, you could use
this:

For iChart = 1 To ActiveSheet.ChartObjects.Count
With ActiveSheet.ChartObjects(iChart)
' do your stuff
End With
Next

- Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top