I am exporting my data to excel through office automation. First three lines
are Report title and subtitle and some other information. Line 4 is coloumn
heading and from line 5 onwards actual data. Based on this data I am
creating column chart. I want to show my column heading as x-axis labels but
it shows 1,2,3,4,.... I dont find how to setup XValue property of chart as
range. Here is my code.

xlColumnClustered = 51
oChart = oleapp.Sheets[1].chartobjects.add(50,225,550,300)
oChart.Activate()
OleApp.ActiveChart.ChartType = xlColumnClustered
OleApp.ActiveChart.SetSourceData(OleApp.Range("B12:M12"))
OleApp.ActiveChart.SeriesCollection.Add("Sheet1!$B$4:$M$4",2,.T.,.T.,.T.)
OleApp.ActiveChart.SeriesCollection[1].HasDataLabels = .T.
OleApp.ActiveChart.HasTitle = .T.
OleApp.ActiveChart.ChartTitle.Caption = "Statewide Rate"
OleApp.ActiveChart.HasLegend = .F.

Can anyone please help.

Thanks.

Re: XValues in excel chart by tom

tom
Wed Apr 09 07:18:02 CDT 2008

Hi,

I would try to record a macro in excel. The macro source then normally gives
a GOOD hint how to do it.
Maybe you find something in the excellent office automation book from
hentzenwerke

greetings
tom


"Sunny" <just4group@hotmail.com> schrieb im Newsbeitrag
news:%23iniDERkIHA.4664@TK2MSFTNGP03.phx.gbl...
>I am exporting my data to excel through office automation. First three
>lines are Report title and subtitle and some other information. Line 4 is
>coloumn heading and from line 5 onwards actual data. Based on this data I
>am creating column chart. I want to show my column heading as x-axis labels
>but it shows 1,2,3,4,.... I dont find how to setup XValue property of chart
>as range. Here is my code.
>
> xlColumnClustered = 51
> oChart = oleapp.Sheets[1].chartobjects.add(50,225,550,300)
> oChart.Activate()
> OleApp.ActiveChart.ChartType = xlColumnClustered
> OleApp.ActiveChart.SetSourceData(OleApp.Range("B12:M12"))
>
> OleApp.ActiveChart.SeriesCollection.Add("Sheet1!$B$4:$M$4",2,.T.,.T.,.T.)
> OleApp.ActiveChart.SeriesCollection[1].HasDataLabels = .T.
> OleApp.ActiveChart.HasTitle = .T.
> OleApp.ActiveChart.ChartTitle.Caption = "Statewide Rate"
> OleApp.ActiveChart.HasLegend = .F.
>
> Can anyone please help.
>
> Thanks.
>
>