J
Joe Cletcher
I need to find the process ID for an Excel application object specified by my
code.--using Interopt Services. No other Excel processes should be running.
Following code demonstrates problem.
DIM aProcess as New Process
DIM MyExcelProcessID As Integer = -1
DIM XlsProcesses() as Process = Process.GetProcessesByName("Excel")
For Each aProcess in XlsProcesses
aProcess.Kill()
Next
DIM xcApp as New Excel.Application
XlsProcesses = Process.GetProcessesByName("Excel")
MyExcelProcessID = XlsProcesses(0).ID
However, if someother program or user opens an Excel process between the
"Dim XlsProcesses..." and the "XlsProcesses = " statements complete then
XlsProcesses(0).ID is not guaranteed to be the correct Process ID for xcApp.
How do I determine the correct Process ID for xcApp?
code.--using Interopt Services. No other Excel processes should be running.
Following code demonstrates problem.
DIM aProcess as New Process
DIM MyExcelProcessID As Integer = -1
DIM XlsProcesses() as Process = Process.GetProcessesByName("Excel")
For Each aProcess in XlsProcesses
aProcess.Kill()
Next
DIM xcApp as New Excel.Application
XlsProcesses = Process.GetProcessesByName("Excel")
MyExcelProcessID = XlsProcesses(0).ID
However, if someother program or user opens an Excel process between the
"Dim XlsProcesses..." and the "XlsProcesses = " statements complete then
XlsProcesses(0).ID is not guaranteed to be the correct Process ID for xcApp.
How do I determine the correct Process ID for xcApp?