A
A
asdz2015-03-17 23:34:19
.NET
asdz, 2015-03-17 23:34:19

Why does Microsoft Excel hang in the process list after manually closing it?

Create a new Excel document to print documents

excelApplication = new Excel.Application();
excelApplication.DisplayAlerts = true;
excelApplication.WindowState = Excel.Enums.XlWindowState.xlMaximized;
excelApplication.Visible = true;

I output everything that is needed, the user himself sends to the printer and closes Excel, but after closing it and closing my program, Microsoft Excel remains hanging in the process lists. Where does it come from if all programs are closed, and how to avoid this?
If done
excelApplication.Quit();
excelApplication.Dispose();

then everything is ok in the task manager, but I need the user to work with the document.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly Pukhov, 2015-03-18
@Neuroware

Obviously, if the program is not closed, it will remain unclosed. You create a process programmatically, so a user's "shutdown" means nothing to it, it waits to be sent a programmatically close command. As an option, you can try to determine the sign that the user has closed and then exit programmatically, or open excel in another way, for example, through Process

M
mayorovp, 2015-03-18
@mayorovp

Here you wrote to close the program, here it is:

excelApplication.Quit();
excelApplication.Dispose();

Didn't you think that these two methods separately from each other also mean something? :)
Quit means exiting the program. This is exactly what you want to avoid - to allow the user to do it themselves. But Dispose means release of the control channel. Try calling Dispose without calling Quit.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question