Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Chart events with embedded charts

Status
Not open for further replies.

MatthewBell

Technical User
Feb 12, 2003
26
GB
Hello, stuck again!

Thanks xlbo for your code to take me to a charts source data.

The problem now is that I have lots of embedded charts in the same worksheet and can only enable events for 1 at a time.

I execute the following code before anything happens to enable events on ChartObject(2) but I'd like all the charts to execute the same event-handler procedure following selection.


Dim MyChart As New EventsEnabler

Sub EnableChartEvents()
Range("A1").Select
Set MyChart.myChartClass = Sheets("Metrics").ChartObjects(2).Chart
End Sub

I then store the event-handler procedure in a Class Module named EventsEnabler as follows:

Public WithEvents myChartClass As Chart

Private Sub myChartClass_Select(ByVal ElementID As Long, ByVal Arg1 As Long, ByVal Arg2 As Long)

Blah Blah Blah

End Sub

This works just fine and dandy for ChartObject(2) or whatever individual ChartObject I specify but, as I mentioned above, I'd like to find a way to apply the same event handler procedure to all the chartobjects embedded in a single worksheet.

Is this possible? Any Takers?

Many thanks for your time.

Matt


 
You may have to use

For each chart in activesheet.charts


Have a look at the chart objects in help file. It might be helpful
 
Cheers lambuhere1

I was starting to think along the lines of a For Next loop.

Problem is I think I then need a new EventsEnabler Class Module for each chart.

Is there any way that line

For Each Chart In ActiveSheet.Charts

Can help me set MyChart.myChartClass to all the embedded charts rather than one?

Unfortunately the help file was particularly unhelpful on this one.

Thanks

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top