Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
PO PO is offline
external usenet poster
 
Posts: 66
Default Chart_select event problem

Hi,

I'm using a class to trap an embedded charts events.

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

If Arg2 < 0 Or ElementID < 3 Then Exit Sub

Dim dblPotential As Double
Dim dblEnergy As Double
Dim sName As String

sName = wksEmbchart.Range("inpName").Cells(Arg2, 1).Value

dblPotential = wksEmbchart.Range("inpName").Cells(Arg2, 2).Value
dblEnergy = wksEmbchart.Range("inpName").Cells(Arg2, 3).Value

...some more code here
End Sub

The code works just fine, there is however one slight problem. The user has
to click the datapoint 2 times. The first click selects the series (Arg2
= -1) and not the point. Is there any way around this, i.e. can the user
click the datapoint without the series getting selected?

Regards
Pete


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Chart_select event problem

Not guranteed to work but should work most of the time (run startChartEvents
to instantiate the withevents class)

' code in a normal module

Dim cls As Class1

Sub startChartEvents()
Set cls = New Class1
Set cls.cht = ActiveSheet.ChartObjects(1).Chart
End Sub

Sub stopChartEvents()
Set cls = Nothing
End Sub


' code in class odule named Class1

Public WithEvents cht As Chart
Private mX As Long, mY As Long

Private Sub cht_MouseMove(ByVal Button As Long, ByVal Shift As Long, _
ByVal x As Long, ByVal y As Long)
mX = x
mY = y
End Sub

Private Sub cht_Select(ByVal ElementID As Long, _
ByVal Arg1 As Long, ByVal Arg2 As Long)
Dim eID As Long, a1 As Long, a2 As Long
If ElementID = xlSeries And Arg2 = -1 Then
Call cht.GetChartElement(mX, mY, eID, a1, a2)
If eID = xlSeries And a1 = Arg1 And a2 0 Then
cht.SeriesCollection(a1).Points(a2).Select
End If
End If
End Sub

Presumably you'll implement some other way to select the entire series!

Regards,
Peter T

"PO" <h wrote in message ...
Hi,

I'm using a class to trap an embedded charts events.

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

If Arg2 < 0 Or ElementID < 3 Then Exit Sub

Dim dblPotential As Double
Dim dblEnergy As Double
Dim sName As String

sName = wksEmbchart.Range("inpName").Cells(Arg2, 1).Value

dblPotential = wksEmbchart.Range("inpName").Cells(Arg2, 2).Value
dblEnergy = wksEmbchart.Range("inpName").Cells(Arg2, 3).Value

...some more code here
End Sub

The code works just fine, there is however one slight problem. The user
has to click the datapoint 2 times. The first click selects the series
(Arg2 = -1) and not the point. Is there any way around this, i.e. can the
user click the datapoint without the series getting selected?

Regards
Pete



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
ComboBox_Click event problem Bert Excel Programming 5 February 21st 09 02:43 PM
Worksheet_Change event problem Ron[_32_] Excel Programming 2 June 23rd 08 04:33 PM
SHdocVw event problem JU Excel Programming 0 March 16th 08 12:39 PM
Problem with Worksheet_Change event Romuald Excel Programming 2 January 19th 04 09:41 AM


All times are GMT +1. The time now is 04:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"