Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing Excel from a window

Status
Not open for further replies.

giacam

Programmer
Joined
Feb 7, 2005
Messages
3
Location
IT
Hi,
I have a window with an hidden frame that creates an Excel object, it does some work and, when all is done, sets the excel object to nothing and then ends the visible window.

Everyting works fine except if the user presses the X to close the window: in that case the Excel application remains up&running. I cannot kill all the "Excel.exe" application, but I have to terminate the right one.

I've tried with the onunload event in the window, but it seems not to work properly, or perhaps I don't know how to manage it (I'm just an ASP beginner).

Can you help ?

Thanks
 
Does your page opens Excel on the browser client or on the web server?
 
It is open on the server. What I do is to create an excel sheet on the server, fill it up with my data and post a link on the client, so it can access the sheet.

Thanks
 
If the user is viewing an embedded Excel document, why is Excel running on the server? Wouldn't it be running on the client machine?

Or do you create an instance of Excel in ASP to build the document in the first place?
 
I create an instance in ASP, I create a new Excel document, put some data and save it. During this elaboration the client displays a modal window ("working in progress...") and when all is done the link to the excel file is returned. Each user (it is for internal use only) has a unique name assigned to the document, so there are no duplicate document files.

I the user closes the browser during this stage, the Excel application remains up on the server, and can only be killed by Task manager. The problem is also that if another user has started another Excel task, I don't know which one is to be killed.



 
Assuming you are already calling Application.Quit()...

Maybe change your order of operations to something like this:
Page #1 contains form allowing user to request new Excel file, form action posts to Page #2

Page #2 is an ASP with no user interface... It will send nothing to the browser. It creates the excel document and then redirects to Page #3

Page #3 receives the name of the new file in the QueryString redirect from Page #2 .... it uses the filename to fetch the file and create user interface.

---

Perhaps if you do it this way then the execution of Page#2 will not be interrupted by the user?

Another thing you could try might be to do the document creation inside an ActiveX object and then make sure you call application.quit and destroy the thing on the Terminate event.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top