Highlighted
Absent Member.
Absent Member.
780 views

How to start Excel using C$SYSTEM in a particular workbook, with pre-populated 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
0 Likes
1 Reply
Highlighted
Absent Member.
Absent Member.

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

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.
0 Likes
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.