Absent Member.
Absent Member.

[archive] ActiveX Excel chart

[Migrated content. Thread originally posted on 25 November 2004]

I want to create a chart using the Excel ActiveX.
I can create an excel worksheet, and reading the cell information, but i can't find the solution to display a chart in my acucobol program using the excel activeX.
Can someone please help me. Perhaps someone has a small example program of displaying charts using Excel ActiveX, which will help me understanding this issue.

1 Reply
Absent Member.
Absent Member.

RE: [archive] ActiveX Excel chart

Originally posted by martje
I want to create a chart using the Excel ActiveX.

       PROGRAM-ID. ExcelChart.
      * Copyright (c) 1996-2001 by Acucorp, Inc.  Users of ACUCOBOL
      * may freely modify and redistribute this program.
      * The purpose of this application is to show how to use MS Excel
      * to create a chart using values we first provide in cells.
       CONFIGURATION                SECTION.
           COPY    "EXCEL.def".
       DATA        DIVISION.
       WORKING-STORAGE              SECTION.
       77  oXL                      HANDLE OF Application.
       77  oBook                    HANDLE OF Workbook.
       77  oSheet                   HANDLE OF Worksheet.
       77  oChartObjects            HANDLE OF ChartObjects.
       77  oChartObject             HANDLE OF ChartObject.
       77  oChart                   HANDLE OF Chart.
       77  oRange                   HANDLE OF Range.

       01  MyTable.
           03 FILLER                OCCURS 10.
              05 MyItem             USAGE HANDLE OF VARIANT OCCURS 2.

       77  I                        PIC 9(3).
       77  J                        PIC 9(3).
       77  MyData                   PIC X(80).
       01  RND-VALUE                PIC 9(12)V9(5).

           CREATE  Application      OF Excel
                   HANDLE           IN oXL.
      *This is for training purposes only. If you don't want to see
      *Excel, remove this line.
           MODIFY  oXL              @Visible = 1.
           MODIFY  oXL              Workbooks::Add()
                   GIVING           oBook.
           INQUIRE oBook            Worksheets::Item(1) IN
           MODIFY  oSheet
                   Range("A1")::Resize(10 , 2)::Value =
           MODIFY  oSheet           ChartObjects()
                   GIVING           oChartObjects.
           MODIFY  oChartObjects    @Add(100, 100, 300, 200)
                   GIVING           oChartObject.
           INQUIRE oChartObject     Chart IN oChart.
           INQUIRE oSheet           Range("A1")::Resize(10 , 2) IN
           MODIFY  oChart           SetSourceData(
                   BY NAME          Source = oRange).

           DESTROY oRange.
           DESTROY oChart.
           DESTROY oChartObject.
           DESTROY oChartObjects.
           DESTROY oSheet.

      *Enforce a close without save, or Excel will prompt you.
           MODIFY  oBook            @Close(BY NAME SaveChanges 0).
           DESTROY oBook.
           MODIFY  oXL              Quit().
      *This next line is very important, otherwise Excel will stick in
           DESTROY oXL.

      *This section depends on the presens of the sample program rand.cbl
      *as provided in the sample directory of an ACUCOBOL-GT development
      *We here fill the variant table with data.

           PERFORM VARYING          I FROM 1 BY 1 UNTIL I > 10
                   PERFORM VARYING  J FROM 1 BY 1 UNTIL J > 2
                                    CALL "RAND" USING
                                    MULTIPLY RND-VALUE BY 50 GIVING
                                    ADD  1 TO RND-VALUE
                                    CALL "C$SETVARIANT" USING
                                         MyItem(I, J)


identification division.
program-id.        rand is resident program.

* Copyright (c) 1996-2003 by Acucorp, Inc.
* Users of ACUCOBOL may freely use this file.

     Every time you perform 'call "rand"' you will get a new random number
     'rnd_value' between the values of 'rnd_from' and 'rnd_to' which
     you specify.

     Based on a publication by Hewlett-Packard for the HP41 calculator.


        working-storage section.
        01  rnd_value          pic 9(12)v9(5) value 0.
        01  rnd_from           pic 9(3)       value 0.
        01  rnd_to             pic 9(3)       value 1.
        01  rnd_form           pic z(12).z(5).
        procedure division.
            perform  24 times
              call "rand" using rnd_value rnd_from rnd_to
              move rnd_value to rnd_form
              display rnd_form
            accept omitted.

environment division.
configuration section.
data division.

working-storage section.
01  int1               double value 0.
01  int2               pic 9(12).
01  time_i             pic 9(8).

linkage section.

01  rnd_value          pic 9(12)v9(5).
01  rnd_from           pic 9(3).
01  rnd_to             pic 9(3).

procedure division using rnd_value rnd_from rnd_to.
    if int1 = 0
       accept time_i from time
       move time_i(7:2) to int1
       compute int1 = int1 / 100
       if (rnd_from - rnd_to) = 0
          move 0 to rnd_from
          move 1 to rnd_to

    compute int1 = int1 * 9821 + 0.211327
    move    int1 to int2
    compute int1 = int1 - int2
    move    int1 to rnd_value
    compute rnd_value = rnd_value * (rnd_to - rnd_from) + rnd_from.

    exit program.
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.