Thread: VBA and charts
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Debra Dalgleish Debra Dalgleish is offline
external usenet poster
 
Posts: 2,979
Default VBA and charts

This gives the number for the chartObject --

Sub GetIndex()
Dim chObj As ChartObject
Set chObj = ActiveChart.Parent

Debug.Print ActiveSheet _
.ChartObjects(chObj.Name).Index

End Sub


Eric wrote:
Hi all. I'm having trouble working with charts in Excel using Visual basic.

What I'm trying to do is take an embedded chart that is selected, copy and paste it, then select the original chart.

The trouble I'm having is that I just can't get visual basic to tell me the index of the active chart!

Msgbox ActiveChart.Index
returns an "Method 'Index' of object '_Chart' failed" error.

Msgbox ActiveChart.name
works, but returns "charts Chart 12" for example. This would be fine if I could then use this to refer to the chart later, but I think the extra "charts" is throwing it off.

Can anyone offer any help?

Eric



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html