Skip to main content

How to start Excel using C$SYSTEM in a particular workbook, with pre-populated values

  • March 10, 2011
  • 2 replies
  • 0 views

[Migrated content. Thread originally posted on 10 March 2011]

Hello all

I'm new to this forum so please excuse any mistakes in protocol...

Can anyone assist with the following:

The operation required is to start Excel from Cobol by using the C$SYSTEM command, passing control to the user and only returning to Cobol after the user closes Excel.

So far the following command opens Excel (blank, with no workbooks/worksheets active):
call "C$SYSTEM" using "C:\\Program Files\\Microsoft Office\\Office12\\EXCEL.exe" 129.

However, as Excel opens, it needs to simultaneously open a specific workbook, and worksheet which has been populated in advance with fields from a given policy record(6 fields on the relevant worksheet are unprotected and variable). The user may then experiment with projected values by changing the unprotected fields, and finally close Excel and return to the Cobol program, where the originally passed values will be refreshed.

Is anyone able to assist?

Thanks a mil
Ruth

2 replies

[Migrated content. Thread originally posted on 10 March 2011]

Hello all

I'm new to this forum so please excuse any mistakes in protocol...

Can anyone assist with the following:

The operation required is to start Excel from Cobol by using the C$SYSTEM command, passing control to the user and only returning to Cobol after the user closes Excel.

So far the following command opens Excel (blank, with no workbooks/worksheets active):
call "C$SYSTEM" using "C:\\Program Files\\Microsoft Office\\Office12\\EXCEL.exe" 129.

However, as Excel opens, it needs to simultaneously open a specific workbook, and worksheet which has been populated in advance with fields from a given policy record(6 fields on the relevant worksheet are unprotected and variable). The user may then experiment with projected values by changing the unprotected fields, and finally close Excel and return to the Cobol program, where the originally passed values will be refreshed.

Is anyone able to assist?

Thanks a mil
Ruth
First, I don't understand why you want to use C$SYSTEM, you would maintain much more control if you launched Excel as a COM service, in which case you can communicate with Excel at full control.

The forum has lot of examples on how to use COM for this.

If you insist on launching Excel using C$SYSTEM, you will first have to write out pre-populated values to the workbook, which I presume would have to be a CSV file then as there is no way you can write to a .xls(x) file except using Excel that I know of. To read data back again, you would have to be able to read those values from the file. Hopefully the user did not use Save As and store the document in any other format but CSV.

I would have done this using COM to invoke Excel, then used the OnChange and/or OnClose events to update the internal values.

[Migrated content. Thread originally posted on 10 March 2011]

Hello all

I'm new to this forum so please excuse any mistakes in protocol...

Can anyone assist with the following:

The operation required is to start Excel from Cobol by using the C$SYSTEM command, passing control to the user and only returning to Cobol after the user closes Excel.

So far the following command opens Excel (blank, with no workbooks/worksheets active):
call "C$SYSTEM" using "C:\\Program Files\\Microsoft Office\\Office12\\EXCEL.exe" 129.

However, as Excel opens, it needs to simultaneously open a specific workbook, and worksheet which has been populated in advance with fields from a given policy record(6 fields on the relevant worksheet are unprotected and variable). The user may then experiment with projected values by changing the unprotected fields, and finally close Excel and return to the Cobol program, where the originally passed values will be refreshed.

Is anyone able to assist?

Thanks a mil
Ruth
First, I don't understand why you want to use C$SYSTEM, you would maintain much more control if you launched Excel as a COM service, in which case you can communicate with Excel at full control.

The forum has lot of examples on how to use COM for this.

If you insist on launching Excel using C$SYSTEM, you will first have to write out pre-populated values to the workbook, which I presume would have to be a CSV file then as there is no way you can write to a .xls(x) file except using Excel that I know of. To read data back again, you would have to be able to read those values from the file. Hopefully the user did not use Save As and store the document in any other format but CSV.

I would have done this using COM to invoke Excel, then used the OnChange and/or OnClose events to update the internal values.