 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Graeme Guest
|
Posted: Fri Apr 29, 2005 11:16 am Post subject: Excel Charts passing it the series |
|
|
Hi
I am using a Excel template with source data on Sheet1 and a linechart on
Sheet2 How do I connect to the chart and then pass it the range/series of
the data on sheet1.
Thanks for any assistance.
|
|
| Back to top |
|
 |
Lee-Z Guest
|
Posted: Fri Apr 29, 2005 11:59 am Post subject: Re: Excel Charts passing it the series |
|
|
You'll be looking for something like Chart.SetSourcedata....
I could give you a long story on this, but the easiest way is to check out
the Excel helpfile...or record a macro in excel (create chart from range of
data) and see what Excel itself makes of it...
regards,
Lee-Z
"Graeme" <gmocke (AT) netscape (DOT) net> wrote
| Quote: | Hi
I am using a Excel template with source data on Sheet1 and a linechart on
Sheet2 How do I connect to the chart and then pass it the range/series of
the data on sheet1.
Thanks for any assistance.
|
|
|
| Back to top |
|
 |
Graeme Guest
|
Posted: Fri Apr 29, 2005 2:14 pm Post subject: Re: Excel Charts passing it the series |
|
|
My first problem is connecting to the existing chart. I have tried all these
excelChart.ConnectTo( ExcelWorkSheet1.ChartObjects(1) as _Chart) ;
excelChart.ConnectTo( ExcelWorkSheet1.ChartObjects('Chart1') as _Chart) ;
excelChart.ConnectTo( ExcelWorkSheet1.ChartObjects('Sheet1') as _Chart) ;
but each time I get the error 'OLE error 800A03EC' I have the macro but that
does not give the name of the chat.
"Lee-Z" <l.vossen (AT) zonnet (DOT) nl> wrote
| Quote: | You'll be looking for something like Chart.SetSourcedata....
I could give you a long story on this, but the easiest way is to check out
the Excel helpfile...or record a macro in excel (create chart from range
of
data) and see what Excel itself makes of it...
regards,
Lee-Z
"Graeme" <gmocke (AT) netscape (DOT) net> wrote in message
news:427217c6 (AT) newsgroups (DOT) borland.com...
Hi
I am using a Excel template with source data on Sheet1 and a linechart
on
Sheet2 How do I connect to the chart and then pass it the range/series
of
the data on sheet1.
Thanks for any assistance.
|
|
|
| Back to top |
|
 |
Lee-Z Guest
|
Posted: Fri Apr 29, 2005 3:24 pm Post subject: Re: Excel Charts passing it the series |
|
|
I'm a bit out of my league here (I use different syntax myself), but have
you tried using [] instead of () ?
ExcelWorkSheet.ChartObjects[1]
ExcelWorkSheet.ChartObjects['Chart1']
Good luck,
Lee-Z
"Graeme" <gmocke (AT) netscape (DOT) net> wrote
| Quote: | My first problem is connecting to the existing chart. I have tried all
these
excelChart.ConnectTo( ExcelWorkSheet1.ChartObjects(1) as _Chart) ;
excelChart.ConnectTo( ExcelWorkSheet1.ChartObjects('Chart1') as _Chart) ;
excelChart.ConnectTo( ExcelWorkSheet1.ChartObjects('Sheet1') as _Chart) ;
but each time I get the error 'OLE error 800A03EC' I have the macro but
that
does not give the name of the chat.
"Lee-Z" <l.vossen (AT) zonnet (DOT) nl> wrote in message
news:427221a2$1 (AT) newsgroups (DOT) borland.com...
You'll be looking for something like Chart.SetSourcedata....
I could give you a long story on this, but the easiest way is to check
out
the Excel helpfile...or record a macro in excel (create chart from range
of
data) and see what Excel itself makes of it...
regards,
Lee-Z
"Graeme" <gmocke (AT) netscape (DOT) net> wrote in message
news:427217c6 (AT) newsgroups (DOT) borland.com...
Hi
I am using a Excel template with source data on Sheet1 and a linechart
on
Sheet2 How do I connect to the chart and then pass it the range/series
of
the data on sheet1.
Thanks for any assistance.
|
|
|
| Back to top |
|
 |
Patrick Shields Guest
|
Posted: Mon May 16, 2005 9:29 pm Post subject: Re: Excel Charts passing it the series |
|
|
"Graeme" <gmocke (AT) netscape (DOT) net> wrote:
| Quote: | My first problem is connecting to the existing chart. I have tried all these
excelChart.ConnectTo( ExcelWorkSheet1.ChartObjects(1) as _Chart) ;
excelChart.ConnectTo( ExcelWorkSheet1.ChartObjects('Chart1') as _Chart) ;
excelChart.ConnectTo( ExcelWorkSheet1.ChartObjects('Sheet1') as _Chart) ;
but each time I get the error 'OLE error 800A03EC' I have the macro but that
does not give the name of the chat.
|
There might be a better way, but I was able to use:
var
lcid:integer;
ChObj: ChartObject;
.....
try
lcid := GetUserDefaultLCID; //LOCALE_USER_DEFAULT ;
ExcelApplication1.Connect;
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks.Add(TOleEnum(xlWBATWorksheet),
lcid));
ExcelWorksheet1.connectTo(ExcelWorkbook1.Worksheets[1] as
ExcelWorksheet);
ChObj:=(ExcelWorksheet1.ChartObjects(EmptyParam, lcid) as
chartObjects).add(0,0,400,300);
ExcelChart1.ConnectTo(ChObj.Chart as ExcelChart);
except
MessageDlg('error connecting to Excel chart',mterror,[mbok],0);
raise;
end;
and then set the source data with something like:
var
cellRange1,cellRange2:OleVariant;
......
cellRange1:='a1'; //upper left cell
cellRange2:='c10'; //lower right cell
......
ExcelChart1.SetSourceData({Source:=}ExcelWorksheet1.Range[cellrange1,cellRange2],{PlotBy
:=row|col} 1);
HTH,
Patrick
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|