Cannot quit from Excel, stucked on the memory

L

Landon

Hi I use MFC Visual C++ 4.2.

I am automating Excel from my application.

My problem is I cannot quit the Excel after the automation process finished!

I checked it still exists on the Process lists and the most DANGEROUS is
everytime the automation function run, it create other Excel and so on. So it
must be out of memory soon.

I have used the app.Quit() method like all the people used but it DOES NOT
work.

What should I do?

Thank you.
 
J

Joseph M. Newcomer

This suggests that you have not properly released the automation interface object, so
there is a reference count greater than 0. Having called Quit(), you will still need to
Release() the object.
joe

Hi I use MFC Visual C++ 4.2.

I am automating Excel from my application.

My problem is I cannot quit the Excel after the automation process finished!

I checked it still exists on the Process lists and the most DANGEROUS is
everytime the automation function run, it create other Excel and so on. So it
must be out of memory soon.

I have used the app.Quit() method like all the people used but it DOES NOT
work.

What should I do?

Thank you.
Joseph M. Newcomer [MVP]
email: [email protected]
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
 
L

Landon

Yes, I also have tried to app.Release() after app.Quit() but it did not work
Joe.

So my code is like this:
// Release dispatch pointers.
range.ReleaseDispatch();
sheet.ReleaseDispatch();

book.Close( covTrue, covOptional, covOptional );
book.ReleaseDispatch();
//book.SetSaved( TRUE );

app.Quit();
app.Release();

Can you please look what do I miss there? If it is possible, can you please
give me the solution by adding / fixing my code above?

I have searched everywhere but I only found the solution in .NET and
JScript. They are totally different with MFC because they have been MANAGED
code so I don't know what to do.

Thank you very much.
 
Top