View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Application Quit does not work at all

That would be as expected but I don't follow how those examples apply to
your other code. In the case where you did effectively did app.visible =
false indeed the instance would close in that scenario. But instead you
could have done



That's not quite equivalent to what the OP is doing but all is working as
would be anticipated. In your demos when automating a new Excel instance
from Access (or Word) the instance either quits or remains open depending on
whether the app was visible or not when all references to it are released.
However this behaviour can vary depending on the app that is controlling the
automation.

Regards,
Peter T


"Joel" wrote in message
...
I discovered something earlier today when opening an application. OI used
this macro from Access

sub OpenExcel

set obj = getobject("c:\TEMP\BOOK1.XLS")
obj.application.visible = true
obj.close
end sub

Using this code left excel opened on the screen with the workbook closed.

I then made one small modification

sub OpenExcel

set obj = getobject("c:\TEMP\BOOK1.XLS")
obj.application.visible = true
obj.application.visible = false
obj.close
end sub

This close excel. To verify that excel really did close I check the Task
Manager and excel was left open in the first case and excel stopped in the
2nd case.

"Peter T" wrote:

A potential problem is holding on to a reference to any workbook after it
has been closed, and similarly any sheet reference (which should be
destroyed before the book reference).

Another thought, before quit make the app visible. Maybe some user dialog
is
being displayed which would certainly prevent the app from closing.

Regards,
Peter T


"Landon" wrote in message
...
Yes, I am sure. What else? Book, books, sheets, sheet?

What inside my mind: this is like you open 2 or 3 documents on Excel
then
you close it one by one and the last one is the Excel application
itself.

I think I have all the documents closed, and the application failed to
be
closed.

I have asked, but I haven't got the answer yet.

Any other idea?

Thanks.