Skip to main content

How is ti possible to add chart elements as axes, axis title, chart title, data lable, data table, legend

with macro recorder i had become following commands in vba

ActiveChart.Legend.LegendEntries(1).Select
ActiveChart.FullSeriesCollection(1).Name = "=""2021"""
ActiveChart.FullSeriesCollection(1).Values = "=Tabelle1!$A$1:$A$5"
ActiveChart.FullSeriesCollection(2).Name = "=""2022"""
ActiveChart.FullSeriesCollection(2).Values = "=Tabelle1!$B$2:$B$5"
ActiveChart.FullSeriesCollection(3).Name = "=""2023"""
ActiveChart.FullSeriesCollection(2).Values = "=Tabelle1!$C$1:$C$5"

in msexcel.cpy i found the following commands

Method: "getLegend".
01 Legend Legend.
invoke returning Legend.
Method: "getChartTitle".
01 ChartTitle ChartTitle.
invoke returning ChartTitle.
Method: "ApplyDataLabels".
01 Type-CBL XlDataLabelsType.
01 LegendKey VARIANT.
01 AutoText VARIANT.
01 HasLeaderLines VARIANT.
invoke using
by value Type-CBL *> [IN][OPTIONAL]
by value LegendKey *> [IN][OPTIONAL]
by value AutoText *> [IN][OPTIONAL]
by value HasLeaderLines *> [IN][OPTIONAL].

but there is no  setChartTitle

The chart is coming, but i not perfect, here my table (as example)

                  A                     B             C           D

1            Country           2021        2022       2023

2             USA                1000       1200       1400

3             Germany            800      1000      1200

4             France               750         950      1150 

5             Japon               1200      1400       1600

i must define the rows-title as "2021", "2022", "2023" and the Chart Data A2:D5

Thanks Chris for your help!

How is ti possible to add chart elements as axes, axis title, chart title, data lable, data table, legend

with macro recorder i had become following commands in vba

ActiveChart.Legend.LegendEntries(1).Select
ActiveChart.FullSeriesCollection(1).Name = "=""2021"""
ActiveChart.FullSeriesCollection(1).Values = "=Tabelle1!$A$1:$A$5"
ActiveChart.FullSeriesCollection(2).Name = "=""2022"""
ActiveChart.FullSeriesCollection(2).Values = "=Tabelle1!$B$2:$B$5"
ActiveChart.FullSeriesCollection(3).Name = "=""2023"""
ActiveChart.FullSeriesCollection(2).Values = "=Tabelle1!$C$1:$C$5"

in msexcel.cpy i found the following commands

Method: "getLegend".
01 Legend Legend.
invoke returning Legend.
Method: "getChartTitle".
01 ChartTitle ChartTitle.
invoke returning ChartTitle.
Method: "ApplyDataLabels".
01 Type-CBL XlDataLabelsType.
01 LegendKey VARIANT.
01 AutoText VARIANT.
01 HasLeaderLines VARIANT.
invoke using
by value Type-CBL *> [IN][OPTIONAL]
by value LegendKey *> [IN][OPTIONAL]
by value AutoText *> [IN][OPTIONAL]
by value HasLeaderLines *> [IN][OPTIONAL].

but there is no  setChartTitle

The chart is coming, but i not perfect, here my table (as example)

                  A                     B             C           D

1            Country           2021        2022       2023

2             USA                1000       1200       1400

3             Germany            800      1000      1200

4             France               750         950      1150 

5             Japon               1200      1400       1600

i must define the rows-title as "2021", "2022", "2023" and the Chart Data A2:D5

Thanks Chris for your help!

a complete book for programming with excel is available under https://www.labiblioteca.mx/llyfrgell/1842.pdf

This are VBA commands, but the most can be translated easyly in cobol

And now my question for Chris, then only OT/MF may be able to solve this question! (Chris, this is for you!)

ActiveChart.FullSeriesCollection(1).Name = "=""2021"""

FullSeriesCollection is object reference without subscript. But the fonction wnat to use a index.

How can this be use in Cobol?

I was able to translate the most commands for charts and become very nice output as Chart with data coming directly over my cobol program, insert directly in excel

Who works with office integration and want to share there experience?


a complete book for programming with excel is available under https://www.labiblioteca.mx/llyfrgell/1842.pdf

This are VBA commands, but the most can be translated easyly in cobol

And now my question for Chris, then only OT/MF may be able to solve this question! (Chris, this is for you!)

ActiveChart.FullSeriesCollection(1).Name = "=""2021"""

FullSeriesCollection is object reference without subscript. But the fonction wnat to use a index.

How can this be use in Cobol?

I was able to translate the most commands for charts and become very nice output as Chart with data coming directly over my cobol program, insert directly in excel

Who works with office integration and want to share there experience?

It looks to me like you need to get a Series object from the full collection using the subscript and then access the Name property on it.

01 Series  object reference.

invoke FullSeriesCollection "getItem" using 1 returning Series

invoke Series "setName" using ""2021""

I haven't tried this but it looks like this is the format to use.


It looks to me like you need to get a Series object from the full collection using the subscript and then access the Name property on it.

01 Series  object reference.

invoke FullSeriesCollection "getItem" using 1 returning Series

invoke Series "setName" using ""2021""

I haven't tried this but it looks like this is the format to use.

Thanks Chris, but this commands don't work and i am testing since any days to found the correct use of this commands.

01 SeriesCollection OBJECT REFERENCE.
01 FullSeriesCollection OBJECT REFERENCE.
01 Series OBJECT REFERENCE.

invoke ActiveChart "SeriesCollection" returning SeriesCollection
invoke ActiveChart "FullSeriesCollection" returning FullSeriesCollection

you 2 command give a ole server error.

i had try with "Item" for your first command, also error

i had try with "Name" for the your second command, also error

i have found the command with "Name" or "Values" or "Xvalues", see my question i had ask

not easy to solve it, i can only hope of your help, Chris!

your command: invoke FullSeriesCollection "getItem" using 1 returning Series

in the description it is used the name field index as variant

cg


It looks to me like you need to get a Series object from the full collection using the subscript and then access the Name property on it.

01 Series  object reference.

invoke FullSeriesCollection "getItem" using 1 returning Series

invoke Series "setName" using ""2021""

I haven't tried this but it looks like this is the format to use.

Chris, the first command works so:

invoke ActiveChart "SeriesCollection" returning SeriesCollection
invoke ActiveChart "FullSeriesCollection" returning FullSeriesCollection


move z'1' to indexfield
invoke FullSeriesCollection "Item" using by reference indexfield
                                                       returning Series

for the next i am working on!

the second command works fine as

invoke Series "SetName" using by reference "=""2025"""

thanks for your help and feedback, four eyes see more the two!

cg


Chris, the first command works so:

invoke ActiveChart "SeriesCollection" returning SeriesCollection
invoke ActiveChart "FullSeriesCollection" returning FullSeriesCollection


move z'1' to indexfield
invoke FullSeriesCollection "Item" using by reference indexfield
                                                       returning Series

for the next i am working on!

the second command works fine as

invoke Series "SetName" using by reference "=""2025"""

thanks for your help and feedback, four eyes see more the two!

cg

I'm glad you got it working.

Looking at the index call again I think it should be the way I have it specified only using by value 1.

invoke FullSeriesCollection "Item" using by value 1 returning Series

But if the way you are specifying it works then you can go with that!


I'm glad you got it working.

Looking at the index call again I think it should be the way I have it specified only using by value 1.

invoke FullSeriesCollection "Item" using by value 1 returning Series

But if the way you are specifying it works then you can go with that!

this field is declared as variant and not as integer

using value 1 give a ole error and z'1' will pass without errors

and for X-Values here the correct command

invoke Series "setXValues" using by reference "=Tabelle1!$E$2:$E$4"

in this range must be the correct value as E2=Germany E3=England E4=France

it is not easy to show the result of excel macro recorder or consult vba command or c# commands, cobol has his own commands

the best way will be to translate the pdf https://www.labiblioteca.mx/llyfrgell/1842.pdf 

only in cobol syntax!!!

He want to do this for the eternity? any older cobol programmers want to do it with me, each other a chapter!