' code in a normal module
Private clsChart As ChartEventClass
Sub StartEvents()
Dim ch As Chart
Set ch = Worksheets("Sheet1").ChartObjects(1).Chart
Set clsChart = New ChartEventClass
Set clsChart.cht = ch
End Sub
' code in a class named ChartEventClass
Public WithEvents cht As Chart
Private Sub cht_Select(ByVal ElementID As Long, ByVal Arg1 As Long, _
ByVal Arg2 As Long)
Dim sMsg As String
Dim sr As Series
Select Case ElementID
Case xlSeries
Set sr = cht.SeriesCollection(Arg1)
sMsg = sr.Name
If Arg2 > 0 Then
sMsg = sMsg & vbCr & "Point " & Arg2
End If
Case xlPlotArea
sMsg = "PlotArea"
' etc
Case Else
sMsg = "ElementID" & ElementID & vbCr & _
"Arg1 " & Arg1 & vbCr & _
"Arg2 " & Arg2
End Select
MsgBox sMsg
End Sub
Put a chart on Sheet1, run StartEvents, select a Series and/or a Point
You may way to add another routing to do
Set clsChart = Nothing
possibly in the Worksheet & Workbook deactivate events
Regards,
Peter T