Top
PowerCOBOL V11.0 Reference
FUJITSU Software

5.60 OpenBook Method

Description:

Executes the Excel open command to open an existing book.

Starts Excel if Excel is not running.

Used in controls:

ExcelConnection

Used in objects:

None.

Parameters:

VT_BSTR - BookNameX(8192)

[VT_I4 - SheetIndexS9(9) COMP-5]

Description of Parameters:

BookName: The name of the Excel book to open.

SheetIndex: The index of the sheet to connect to within the Excel book. Data is exchanged with this sheet, however, the sheet is not selected in Excel.
Each sheet has a tab in Excel (by default labeled "Sheet1", "Sheet2", "Sheet3"). The index numbers the sheets from left to right 1, 2, 3...

Return value:

VT_I4 - ReturnValueS9(9) COMP-5

Zero or greater indicates normal completion.
Negative indicates an error.

Example:

WORKING-STORAGE SECTION.
01 ExcelBookName  PIC X(20).
01 ExcelSheetIndx PIC S9(9) COMP-5.
01 ReturnValue    PIC S9(9) COMP-5.
PROCEDURE       DIVISION.
* Opens the "my.xls" book and goes 
*  to page 2
    MOVE "C:\my.xls" TO ExcelBookName
    MOVE 2 TO ExcelSheetIndx
    INVOKE CmExcel1 "OpenBook"
      USING     ExcelBookName
                ExcelSheetIndx
      RETURNING ReturnValue

Backward compatibility
method name:

OPENEXCELSHEET

Backward compatibility
arguments:

X(260)