View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Eric Eric is offline
external usenet poster
 
Posts: 1,670
Default Excel Won't Quit

I'm experiencing the same issue, just through .Net Interop. I've also
followed Jim Cone's recommendations on the order of how you exit out, and it
doesn't work either. How do I kill a process in VB.Net?



"Inbar" wrote:

OK, in this case - you would to "kill" the EXCEL process. You can do this
with simple C# code. Let me know if you want help.

"Rex" wrote:

I tried both of your examples and in both cases, Excel remains in the process
list after my program ends. The fact that both of these as well as Inbar's
suggestions all fail makes me think there's something wrong in my
environment. In fact, the only way I've been able to get Excel to quit is to
*not* do the .Open. If I comment out the .Open and .Close lines, it works
fine. (Well, "work" is probably an exaggeration, but Excel goes away after
the Set XL=Nothing.)

Here's some more info, in case it means anything to anyone: I'm using VB
6.0 on XP SP2. Excel 2000 (9.0.6926 SP-3). The reference in my project is
to Microsoft Excel 9.0 Object Library.

Rex

"keepITcool" wrote:


you're using a mix of early and latebound code..
plus it may be easier to set a reference to the opened workbook
both the routines close completely on my machine..
(even if you set xl.Visible = TRUE
so you can test/see what's happening..)



Sub Early()
Dim XL As Excel.Application
Dim WB As Excel.Workbook
Set XL = New Excel.Application
Set WB = XL.Workbooks.Open("C:\temp\AnyOld.XLS")
WB.Close False
XL.Quit
Set XL = Nothing
End Sub

Sub Late()
Dim XL As Object
Dim WB As Object
Set XL = CreateObject("Excel.Application")
Set WB = XL.Workbooks.Open("C:\temp\Anyold.xls")
WB.Close False
XL.Quit
Set XL = Nothing
End Sub





--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Rex wrote :

After running this code, Excel remains:
Dim XL As Excel.Application
Set XL = CreateObject("Excel.Application")
XL.Workbooks.Open "C:\TEMP\AnyOld.XLS"
XL.Workbooks.Item(1).Close False
XL.Quit
Set XL = Nothing
Also tried .Close True and tried omitting .Close call.

What am I missing?
Rex