PC Review


Reply
Thread Tools Rate Thread

Chart events

 
 
kalle
Guest
Posts: n/a
 
      3rd May 2010


Hello

I have searched the web to find out how to use events in a chart but
without success.
I found some code, but it does not work for me.

Can someone help me please?

Thanks in advance

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      3rd May 2010
' 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

"kalle" <(E-Mail Removed)> wrote in message
news:%23%(E-Mail Removed)...
>
>
> Hello
>
> I have searched the web to find out how to use events in a chart but
> without success.
> I found some code, but it does not work for me.
>
> Can someone help me please?
>
> Thanks in advance
>
> *** Sent via Developersdex http://www.developersdex.com ***



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Chart events kalle Microsoft Excel Programming 1 3rd May 2010 05:44 PM
Chart events PO Microsoft Excel Programming 2 17th Sep 2009 09:55 AM
Chart Events... =?Utf-8?B?SmF5V2Vz?= Microsoft Excel Programming 1 15th Jun 2007 06:14 PM
Chart Events =?Utf-8?B?Ukxhbmc=?= Microsoft Excel Programming 2 9th Aug 2006 04:13 PM
enabling chart events for an embedded chart =?Utf-8?B?V2F6b29saQ==?= Microsoft Excel Programming 2 26th Jan 2006 01:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:02 PM.