Excel SeriesCollection Problem

Giganews Newsgroups
Subject:Excel SeriesCollection Problem
Posted by: elisabeth zander
Date:Fri, 23 Oct 2009

Hi: I am using early binding to insert a couple of charts in a workbook using Delphi 7. The first one goes through my procedure fine. When I next call the procedure for a second chart, it throws an ole error when I add the series to the seriescollection. I tried making the series name a different variable, changing the index, but no luck. Help please.
Thanks
Libby

procedure TWebModule1.makeuvchart(uv:integer;ws2:_worksheet; cc:Colorref; tbl_name:string; yearselected:integer);
        var
        cchart:ExcelChart;
        cseries,cseries1:Series;
        cchartgroup:ChartGroup;
begin
        cchart:= Excel.Workbooks.Item[1].Sheets.add(EmptyParam, EmptyParam,
          1,xlchart,0) as ExcelChart;
        if uv=1 then
        begin
              cseries:=  cchart.SeriesCollection(1,0) as Series;  //works fine
              cseries.Name:='Units';
              cseries.Values:=ws2.Range['A1','J1'];
              cseries.XValues:=ws2.Range['A5','J5']
        end
        else
        begin
              cseries:=  cchart.SeriesCollection(1,0) as Series;  // ole error
              cseries.Name:='US$M';
              cseries.Values:=ws2.Range['A1','J1'];
              cseries.XValues:=ws2.Range['A10','J10'];

Replies