Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Excel.Application - series.name (from Delphi 5)

761 views
Skip to first unread message

Daniel Líberman

unread,
Dec 20, 2001, 8:38:13 AM12/20/01
to
Hi, everybody.
I'm having a serious problem here.
I create an Excel application OLE object from my code, using Delphi 5.
Well, all I have to do is: (1) generate a sheet with some data taken from my
database, and (2) plot a chart using the values stored on cells of this
sheet. Everything was going fine in the developing time, but... my Excel is
the XP, English version. When I try to run it in a diferent language, some
strange things happen, and it doesn't work fine. This is not a problem of
version, I mind, because I uninstalled the Office XP from my PC and
installed the Office 97 (still English), and it works... but running my
program in a workstation where is installed the Office 2000, but the
Portuguese version, it didn't work!
Well, would be a problem of the method identifiers (which could change
with language). But... it's not. If a method is not found when I call, the
error message is: "Method 'XXX' not supported by automation object". But the
real message error that I have is "Unable to set the YYY property of the
Series class". This method, YYY, may be "Name", "Values" and "XValues". And
that's the problem.
In addition, it occurs when I try to store strings representing RANGES
in the properties Name, Values or XValues, in the object
"ExcelApp.ActiveChart.SeriesCollection.Item[n]", e.g., '=Data!R7C8', or
'=Data!R8C2:R32C2'. It is EXACTLY the same format used when I do the same
steps, but directly in Excel, recording a macro. But... in my workstation it
works (English version of Office), and in my frend's (Portuguese version) it
does not.

Trying to clarify:

--> Code generated recording my macro:

ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "=Data!R8C1:R32C1"
ActiveChart.SeriesCollection(1).Values = "=Data!R8C2:R32C2"
ActiveChart.SeriesCollection(1).Name = "=Data!R7C2"

* important detail: in the Portuguese version the code generated for the
macro in Excel is the same!!!

--> My code in Dephi 5:

// ....
Excel := CreateOLEObject ('Excel.Application');
//
// ... (generates sheet)
//
Excel.Charts.Add;
Excel.ActiveChart.ChartType := xlColumnClustered
Excel.ActiveChart.ChartType := xlLineMarkers;
//
// ... (create series with SeriesCollection.NewSeries)
//
// The problem is below! This code works only in computers where is
// installed the English version!
//
Excel.ActiveChart.SeriesCollection.Item[1].Name := '=Data!R7C2';
Excel.ActiveChart.SeriesCollection.Item[1].XValues :=
'=Data!R8C1:R32C1';
Excel.ActiveChart.SeriesCollection.Item[1].Values := '=Data!R8C2:R32C2';


--> I does work this way:

Excel.ActiveChart.SeriesCollection.Item[1].Name := 'Name';
Excel.ActiveChart.SeriesCollection.Item[1].XValues :=
VarArrayOf([1,2,3]);
Excel.ActiveChart.SeriesCollection.Item[1].Values :=
VarArrayOf([1,2,3]);


... i.e., it's a problem with the string that defines the range of cells!
Because with constant values, it works in any language!

=-------//-------=

Well... if somebody have some idea... and please could tell me... :)

[]s!
Daniel.

--
Daniel Valim Líberman dan...@ram.com.br
RAM Computer Systems www.ram.com.br

Fudiotes, desencatum.
Vita brevis...


Tushar Mehta

unread,
Dec 20, 2001, 11:25:16 PM12/20/01
to
I don't know anything about international support within XL, so this is
sheer speculation.

While I don't know why your code doesn't work, have you tried the
alternative way of specifying the xvalues. From XL help:

Charts("Chart1").SeriesCollection(1).XValues = _
Worksheets("Sheet1").Range("B1:B5")

I recorded the creation of a chart and got the same stuff you got, i.e.,

ActiveChart.SeriesCollection(1).XValues = "=Sheet1!R4C1:R6C1"
ActiveChart.SeriesCollection(1).Values = "=Sheet1!R4C2:R6C2"
ActiveChart.SeriesCollection(1).Name = "=Sheet1!R3C2"

Then, I tried

ActiveChart.SeriesCollection(1).XValues = ActiveSheet.Range("A4:A6")
ActiveChart.SeriesCollection(1).Values = ActiveSheet.Range("b4:b6")
ActiveChart.SeriesCollection(1).Name = ActiveSheet.Range("B3")

and got the same result.

You might want to try it.
--
Regards,

Tushar Mehta
www.tushar-mehta.com
MVP MS Excel
--

In <OpPZoPViBHA.2212@tkmsftngp03>, Daniel Líberman <dan...@ram.com.br>
wrote

0 new messages