Highlighted
Absent Member.
Absent Member.
377 views

[archive] stopping Excel

[Migrated content. Thread originally posted on 19 September 2007]

I have a program that creates an excel spreadshhet.

When it has completed the generation of the spreadsheet, the program makes it visible so that the user can then work with it.

What I want to do is allow the excel process to continue, whilst the ACU program completes via an exit program and returns to the menu system.

If I do not 'close' excel in the ACU program, then even when the user completes his activities in Excel by save and exit, or abandon (or whatever method to exit Excel) the excel process continues as a process. At a shutdown it even asks if I want to save 'book1'. Another run of this program creates yet another instance of Excel. This is not helpful.

If I do the 'close' of the excel in the ACU program, the excel sheet disappears - again not very helpful.

If I wait for the user to finish in Excel and he actuaklly chooses to save and exit, I get a failure on the 'Excel close' as I do not know if the process has stopped or not.

I do not really want to save the excel file away and then launch excel as I do not want to create loads of small excel files the user may not need.

Does anyone know the trick I need here?
0 Likes
5 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] stopping Excel

Hi,

We allow an export to excel from our application.
Example, we have an advanced sales analysis screen, and there is an option to dump the data to excel.
We do exactly that, create an instance of excel, transfer all the data from the sales analysis grid to excel. Then we make excel visible and carry on with whatever the user wants to do next.

If they decide to quit and do something else then fine, but its up to them to close the excel session that they started which has to happen, either the user does it now or when when is shutdown.
If they decide to be daft and dump the same screen to excel many times, then so be it, X number of excel sessions will be running.

Now, if I close the sessions in excel, then yes it does ask if I want to save book1.xls, if I choose No, the excel process is removed from task manager.

If I choose save as and then close, excel does not ask if I want to save book1.xls, its just closes and the process is again removed from task manager.

Shaun
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] stopping Excel

Hi Shaun

In your example, what actually removes the excel process?

If I start Excel, and then close down my ACu runtime, The Excel instance is still running Ok with the data I populated it with. But, if I then exit Excel (with or without saving), although Excel disappears to all intents and purposes, the process is still active in task manager. This behaviour seems to be different from that which you describe?

I attach a simple program, loads excel, populates a few cells and exits. The excel process created seems to stay whatever way i leave excel.

What am I not doing?

Keith
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] stopping Excel

My Dear Micr35180:

Why don't you try:

MODIFY myxlsapp-hdl Quit()


Of course: myxlsapp-hld is the handle of the Excel you receive when you created the connection.

My regards and keep on trying.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] stopping Excel

Keith,

Simply DESTROY the Excel application handle. If you Quit or Exit or anything else, Excel will actually quit or exit, etc. By DESTROYing the Excel application handle from within the runtime, it releases that process. Then, when the user quits on their own, you shouldn't see it in the task manager anymore.

Rob
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] stopping Excel

Rob - absolutely - many thanks.

Keith
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.