Hi,
This works for me. I hope it helps you.
Private Function closeExcel() As Short
Dim count As Short = 0
Dim excelInstance As System.Diagnostics.Process
Dim excelInstances() As Process =
System.Diagnostics.Process.GetProcessesByName("Exc el")
For Each excelInstance In excelInstances
Try
excelInstance.Close() '<-- you can use close or kill .. up to you
excelInstance.Kill()
count += 1
Catch ex As Exception
End Try
Next
Return count
End Function
http://www.kjmsolutions.com/datasetarray.htm
"DGT3" wrote in message
:
I have been working on making excel go away, only in VC++, using the
example
code I found in KB articles 186120, 186122, and 179706.
So far I have narrowed it down to using the Open method of the Workbooks
object.
If I start Excel, add a workbook, put some information in it, save the
workbook and call the Quit method on the application object, Excel
disappears
from the system's task list, just like its supposed to.
If I start Excel, get a reference to the workbooks object, though
GetWorkbooks, and open a workbook, (with no other action taking place)
Excel
disappears from view, but won't exit the systems task list.
Next approach is grabbing a snapshot of the processes in the system,
before
and after Excel is starting, then killing off the new copy of Excel when I
need Excel to exit. Not pretty, but have no other ideas at present...
There is a lot of extra potential for my application if I can solve this,
any help is appreciated.
David
"Naveen" wrote:
Jim
Your note has been extremely helpful.
Before I read this I had been searching for a while to resolve the
persistence of EXCEL.EXE process.
Thanks very much.
Naveen