PDA

View Full Version : Chart object fails



Alan Júlio
11-13-2009, 06:07 AM
Hi folks,

I have a problem in my code. When I try to access the Axes method or any other property or method of Chart Object (which belongs to ChartM object), VBA stops because a runtime error (1004) saying that the method (or property) of the '_Chart' failed.


Dim chartM As ChartObject: Set chartM = sheetXi.ChartObjects.Add(100, 10, 600, 200)
Dim serieM As Series: Set serieM = hartM.Chart.SeriesCollection.NewSeries
serieM.Values = mSerieM: serieM.XValues = mSerieIndex

With chartM 'formatting
.Name = "Amostras para média"
With .Chart
.ChartType = xlLine
.PlotArea.Interior.Color = vbWhite
With .Axes(xlValues).MajorGridlines.Border 'the problem is here
.ColorIndex = 57
.Weight = xlHairline
.LineStyle = xlDot
End With
End With
End With


Did somedy have this problem? May you help me?

Thanks. See u.

Bob Phillips
11-13-2009, 06:47 AM
Where/how does mSerieM and mSerieIndex get set?

Alan Júlio
11-13-2009, 07:01 AM
They are variant variables wich contains arrays of values and categories, and are set previously with success.
The content is get from a mdb file using DAO 3.6.

Bob Phillips
11-13-2009, 07:24 AM
I think it is just one s too many.

Try



With .Axes(xlValue).MajorGridlines.Border 'the problem is here

Alan Júlio
11-13-2009, 08:19 AM
so stupid I am... :banghead:

many thanks, xld!:thumb

Dave
11-13-2009, 08:27 AM
"hartM.Chart.SeriesCollection.NewSeries "...I don't understand how this works? Shouldn't it be...
chartM.Chart.SeriesCollection.NewSeries
HTH. Dave

Alan Júlio
11-13-2009, 09:01 AM
It just creates a new series in the collection of the chart wich you have to set up.

What specifically you don't understand?

Dave
11-13-2009, 09:03 AM
note the "hartM" no "c" in your posted code :) Dave

Alan Júlio
11-13-2009, 09:11 AM
Ohh yeah, but it chartM ;)

I must have edited the code... sorry