Skip to main content

Working with excel document

  • June 16, 2021
  • 3 replies
  • 0 views

Jaap Voerman
Forum|alt.badge.img+1

I use a excel.def for reading an ?.xlsx.

The program is reading the whole document and after that it is renamed to an other directory.

This is done with CALL "RENAME"  file-type "S", and the STATUS  PIC  9(09)  COMP-4.

In STATUS is a zero but the document is not to the other directory.

Is there a way, when opening the document, to know if an other user has opend the same document?

3 replies

Stephen Hjerpe
  • Participating Frequently
  • June 17, 2021

I use a excel.def for reading an ?.xlsx.

The program is reading the whole document and after that it is renamed to an other directory.

This is done with CALL "RENAME"  file-type "S", and the STATUS  PIC  9(09)  COMP-4.

In STATUS is a zero but the document is not to the other directory.

Is there a way, when opening the document, to know if an other user has opend the same document?

When you say reading the whole document, are you using a function within excel.def like @Read, or are you using COBOL syntax, read next record, or are you viewing the spreadsheet on the screen and consider that as reading the whole document?. The excel.def exposes either ActiveX or .Net functions of the software (in this case Excel). If you want to do a Save or SaveAs you need to use those types of functions in the excel.def.


Jaap Voerman
Forum|alt.badge.img+1
  • Author
  • Participating Frequently
  • June 22, 2021

When you say reading the whole document, are you using a function within excel.def like @Read, or are you using COBOL syntax, read next record, or are you viewing the spreadsheet on the screen and consider that as reading the whole document?. The excel.def exposes either ActiveX or .Net functions of the software (in this case Excel). If you want to do a Save or SaveAs you need to use those types of functions in the excel.def.

My 'reading' is the use of the cobol statements modify and inquire. The solution i build is reading/checking orderlines and put them in Version files. Do you have a solution for my question?


Stephen Hjerpe
  • Participating Frequently
  • June 24, 2021

My 'reading' is the use of the cobol statements modify and inquire. The solution i build is reading/checking orderlines and put them in Version files. Do you have a solution for my question?

In the excel.def is there a Saveas function? Something that would alow you to:

MODIFY myWorkBook SaveAs(
BY NAME Filename "myfile.xls",
BY NAME FileFormat xlExcel7,

*[Class: @_Workbook] _SaveAs
METHOD, 284, @_SaveAs,
"VARIANT" @Filename, TYPE 12,
"VARIANT" @FileFormat, TYPE 12,
"VARIANT" @Password, TYPE 12,
"VARIANT" @WriteResPassword, TYPE 12,
"VARIANT" @ReadOnlyRecommended, TYPE 12,
"VARIANT" @CreateBackup, TYPE 12,
"XlSaveAsAccessMode" @AccessMode, TYPE 3,
"VARIANT" @ConflictResolution, TYPE 12,
"VARIANT" @AddToMru, TYPE 12,
"VARIANT" @TextCodepage, TYPE 12,
"VARIANT" @TextVisualLayout, TYPE 12
OPTIONAL 11