BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Excel Charts passing it the series

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Graeme
Guest





PostPosted: Fri Apr 29, 2005 11:16 am    Post subject: Excel Charts passing it the series Reply with 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
Lee-Z
Guest





PostPosted: Fri Apr 29, 2005 11:59 am    Post subject: Re: Excel Charts passing it the series Reply with 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

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





PostPosted: Fri Apr 29, 2005 2:14 pm    Post subject: Re: Excel Charts passing it the series Reply with 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

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





PostPosted: Fri Apr 29, 2005 3:24 pm    Post subject: Re: Excel Charts passing it the series Reply with quote

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





PostPosted: Mon May 16, 2005 9:29 pm    Post subject: Re: Excel Charts passing it the series Reply with quote

"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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.