Problems with Excel Object Library

  • Thread starter Thread starter Sergio Gallardo Contreras
  • Start date Start date
S

Sergio Gallardo Contreras

Hi,

I´m using Microsoft Excel 11.0 Object Library in an ASP.NET web
application to generate a XLS file. It works fine but sometimes the
EXCEL.EXE process remains in the computer, and when I try to kill it,
the message "Access denied." is showed. I try to kill the process with
the System.Diagnostics methods, obtainin the process ID and then killing
it, It works too, but sometimes when the method Process.GetProcess is
called, the exception "Access denied." is raised. This is some of the code

Dim oXL As New Excel.Application

Dim aProcesses() As Process = Process.GetProcesses

For i = 0 To aProcesses.GetUpperBound(0)
If aProcesses(i).MainWindowHandle.ToString = oXL.Hwnd.ToString Then
intExcelPID = aProcesses(i).Id
Exit For
End If
Next


Can someone help me, thanks.
 
¤ Hi,
¤
¤ I´m using Microsoft Excel 11.0 Object Library in an ASP.NET web
¤ application to generate a XLS file. It works fine but sometimes the
¤ EXCEL.EXE process remains in the computer, and when I try to kill it,
¤ the message "Access denied." is showed. I try to kill the process with
¤ the System.Diagnostics methods, obtainin the process ID and then killing
¤ it, It works too, but sometimes when the method Process.GetProcess is
¤ called, the exception "Access denied." is raised. This is some of the code
¤
¤ Dim oXL As New Excel.Application
¤
¤ Dim aProcesses() As Process = Process.GetProcesses
¤
¤ For i = 0 To aProcesses.GetUpperBound(0)
¤ If aProcesses(i).MainWindowHandle.ToString = oXL.Hwnd.ToString Then
¤ intExcelPID = aProcesses(i).Id
¤ Exit For
¤ End If
¤ Next
¤
¤
¤ Can someone help me, thanks.

See if the following helps:

Office application does not quit after automation from Visual Studio .NET client
http://support.microsoft.com/?kbid=317109


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Back
Top