Home All Groups Group Topic Archive Search About

Problems with Excel Object Library

Author
15 Feb 2006 2:28 PM
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.

Author
15 Feb 2006 5:26 PM
Paul Clement
On Wed, 15 Feb 2006 08:28:22 -0600, Sergio Gallardo Contreras <seg***@hotmail.com> wrote:

¤ 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)