Excel 2007 Charting

M

Michael K

I created a small sample template of a chart I created on a logarithmic scale using approximately 200 data points.

The workbook is initialized with events on the chart so when a mouse down click action is performed on the chart a msg box pops explaining that a data point has been clicked otherwise nothing else happens.

The behavior I'm experiencing is that Excel 2007 will crash. I cannot produce the error on any earlier versions of Excel. The error is occurs at random but I believe the what is causing Excel to crash is an issue on the GetChartElement method for the active chart. The crash can be replicated in Excel 2007 with no service packs or with service pack 2 installed.

I can provide the sample chart through email for anyone wishing to do a code review and\or to reproduce the error. The code on the sheet is simple enough:

Option Explicit

Public WithEvents SampleChart As Chart

Public Sub InitSampleChart()
If SampleChart Is Nothing Then Set SampleChart = ThisWorkbook.Worksheets("Sheet1").ChartObjects("Test").Chart
End Sub

Private Sub Worksheet_Activate()
InitSampleChart

SampleChart.Refresh
End Sub

Private Sub SampleChart_MouseDown(ByVal Button As Long, ByVal Shift As Long, ByVal x As Long, ByVal y As Long)
Dim ElementID As Long
Dim Arg1 As Long
Dim Arg2 As Long

ActiveChart.GetChartElement x, y, ElementID, Arg1, Arg2 '<-- suspect line

If ElementID = xlSeries Then
MsgBox "Found Point!"
End If
End Sub






Submitted via EggHeadCafe - Software Developer Portal of Choice
Win a free Professional license of CodeSmith Generator 5.2!
http://www.eggheadcafe.com/tutorial...sional-license-of-codesmith-generator-52.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top