Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Closing die hard process EXCEL.EXE

Hi,
I have a VB.NET program that opens an EXCEL workbook. In this program I modify the workbook, I save it, then I close it.
The code is like this:

Sub mySub()

Dim excelApp As Excel.Application
Dim excelDoc As Excel.Workbook

excelApp = New Excel.Application
excelDoc = excelApp.Workbooks.Open("c:\temp\test.xls")

'code that update the workbook....

excelDoc.Close(True)
excelDoc = Nothing

excelApp.Quit()
excelApp = Nothing

End Sub


I have no errors, but the EXCEL.EXE process keep alive after the execution.

The EXCEL.EXE process starts on statement:

excelApp = New Excel.Application

and it should die on statement:

excelApp.Quit()


It's right?

Thanks for help!

franx
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Closing die hard process EXCEL.EXE

Unless you have an unreleased reference to an object in the Excel
application. This can happen if you don't fully qualify all your
references.

--
Regards,
Tom Ogilvy


"Francesco Geri" wrote in message
...
Hi,
I have a VB.NET program that opens an EXCEL workbook. In this program I
modify the workbook, I save it, then I close it.
The code is like this:

Sub mySub()

Dim excelApp As Excel.Application
Dim excelDoc As Excel.Workbook

excelApp = New Excel.Application
excelDoc = excelApp.Workbooks.Open("c:\temp\test.xls")

'code that update the workbook....

excelDoc.Close(True)
excelDoc = Nothing

excelApp.Quit()
excelApp = Nothing

End Sub


I have no errors, but the EXCEL.EXE process keep alive after the execution.

The EXCEL.EXE process starts on statement:

excelApp = New Excel.Application

and it should die on statement:

excelApp.Quit()


It's right?

Thanks for help!

franx


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Closing die hard process EXCEL.EXE

franx
try forcing garbage collection

excelApp = nothing
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
GC.WaitForPendingFinalizers()

This works for me in C# the Vb code wont be far different.
as you say its a die hard process!

cheers
Simon
"Francesco Geri" wrote in message
...
Hi,
I have a VB.NET program that opens an EXCEL workbook. In this program I
modify the workbook, I save it, then I close it.
The code is like this:

Sub mySub()

Dim excelApp As Excel.Application
Dim excelDoc As Excel.Workbook

excelApp = New Excel.Application
excelDoc = excelApp.Workbooks.Open("c:\temp\test.xls")

'code that update the workbook....

excelDoc.Close(True)
excelDoc = Nothing

excelApp.Quit()
excelApp = Nothing

End Sub


I have no errors, but the EXCEL.EXE process keep alive after the execution.

The EXCEL.EXE process starts on statement:

excelApp = New Excel.Application

and it should die on statement:

excelApp.Quit()


It's right?

Thanks for help!

franx


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Closing die hard process EXCEL.EXE

Thanks Tom,
I have tryed with a new function that opens and immediately closes excel
application (no unreleased reference, I'm sure) and I have the same problem.
In reality I have this problem on an ASP.NET Application, otherwise in
VB.NET I can solve the problem by a call to GC.Collect...

franx

"Tom Ogilvy" ha scritto nel messaggio
...
Unless you have an unreleased reference to an object in the Excel
application. This can happen if you don't fully qualify all your
references.

--
Regards,
Tom Ogilvy


"Francesco Geri" wrote in message
...
Hi,
I have a VB.NET program that opens an EXCEL workbook. In this program I
modify the workbook, I save it, then I close it.
The code is like this:

Sub mySub()

Dim excelApp As Excel.Application
Dim excelDoc As Excel.Workbook

excelApp = New Excel.Application
excelDoc = excelApp.Workbooks.Open("c:\temp\test.xls")

'code that update the workbook....

excelDoc.Close(True)
excelDoc = Nothing

excelApp.Quit()
excelApp = Nothing

End Sub


I have no errors, but the EXCEL.EXE process keep alive after the
execution.

The EXCEL.EXE process starts on statement:

excelApp = New Excel.Application

and it should die on statement:

excelApp.Quit()


It's right?

Thanks for help!

franx




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Closing die hard process EXCEL.EXE

Thanks Simon,

I have added an explicit call to GC.Collect.
In this way my VB.NET program works well, but the same code in an ASP.NET
application doesen't work...
Unfortunately my final application must be an ASP.NET application...
The EXCEL process keeps alive after the applicatoin ends, and also if I kill
asp_net process or restart iis the process keeps alive...

Do you know if I can read the PID of Excel.Application object? If yes I can
kill the process... It's a bad idea, I know, but....

Franx


"Simon Murphy" ha scritto nel messaggio
...
franx
try forcing garbage collection

excelApp = nothing
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
GC.WaitForPendingFinalizers()

This works for me in C# the Vb code wont be far different.
as you say its a die hard process!

cheers
Simon
"Francesco Geri" wrote in message
...
Hi,
I have a VB.NET program that opens an EXCEL workbook. In this program I
modify the workbook, I save it, then I close it.
The code is like this:

Sub mySub()

Dim excelApp As Excel.Application
Dim excelDoc As Excel.Workbook

excelApp = New Excel.Application
excelDoc = excelApp.Workbooks.Open("c:\temp\test.xls")

'code that update the workbook....

excelDoc.Close(True)
excelDoc = Nothing

excelApp.Quit()
excelApp = Nothing

End Sub


I have no errors, but the EXCEL.EXE process keep alive after the
execution.

The EXCEL.EXE process starts on statement:

excelApp = New Excel.Application

and it should die on statement:

excelApp.Quit()


It's right?

Thanks for help!

franx





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Closing die hard process EXCEL.EXE

Franx
try he
http://www.csharphelp.com/archives2/archive334.html
(I'm sure there will be a VB version somewhere)
using windows management instruments should get you your pid, and if you are
on win xp or 2003 you can then use kill.exe.
In terms of this being a bad idea - automating Excel on a server is bad idea
and strongly discouraged by MS. So its too late to worry now!
We did this in VB6 a few years ago and it was a challenge, in fact you could
try wrapping Excel in a vb6 wrapper to get better control maybe?

Or is there a way you can wrap the excel bit in its own assembly to isolate
it, then maybe use GC?
Another possibility is one of the many spreadsheet controls (eg spreadgear -
but google spreadsheet and .net, there are loads now)
Good luck
cheers
Simon


"Francesco Geri" wrote in message
...
Thanks Simon,

I have added an explicit call to GC.Collect.
In this way my VB.NET program works well, but the same code in an ASP.NET
application doesen't work...
Unfortunately my final application must be an ASP.NET application...
The EXCEL process keeps alive after the applicatoin ends, and also if I
kill asp_net process or restart iis the process keeps alive...

Do you know if I can read the PID of Excel.Application object? If yes I
can kill the process... It's a bad idea, I know, but....

Franx


"Simon Murphy" ha scritto nel messaggio
...
franx
try forcing garbage collection

excelApp = nothing
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
GC.WaitForPendingFinalizers()

This works for me in C# the Vb code wont be far different.
as you say its a die hard process!

cheers
Simon
"Francesco Geri" wrote in message
...
Hi,
I have a VB.NET program that opens an EXCEL workbook. In this program I
modify the workbook, I save it, then I close it.
The code is like this:

Sub mySub()

Dim excelApp As Excel.Application
Dim excelDoc As Excel.Workbook

excelApp = New Excel.Application
excelDoc = excelApp.Workbooks.Open("c:\temp\test.xls")

'code that update the workbook....

excelDoc.Close(True)
excelDoc = Nothing

excelApp.Quit()
excelApp = Nothing

End Sub


I have no errors, but the EXCEL.EXE process keep alive after the
execution.

The EXCEL.EXE process starts on statement:

excelApp = New Excel.Application

and it should die on statement:

excelApp.Quit()


It's right?

Thanks for help!

franx





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Closing die hard process EXCEL.EXE

Franx
try he
http://www.csharphelp.com/archives2/archive334.html
(I'm sure there will be a VB version somewhere)
using windows management instruments should get you your pid, and if you are
on win xp or 2003 you can then use kill.exe.
In terms of this being a bad idea - automating Excel on a server is bad idea
and strongly discouraged by MS. So its too late to worry now!
We did this in VB6 a few years ago and it was a challenge, in fact you could
try wrapping Excel in a vb6 wrapper to get better control maybe?

Or is there a way you can wrap the excel bit in its own assembly to isolate
it, then maybe use GC?
Another possibility is one of the many spreadsheet controls (eg spreadgear -
but google spreadsheet and .net, there are loads now)
Good luck
cheers
Simon
(repost - first one disappeared)
"Francesco Geri" wrote in message
...
Thanks Simon,

I have added an explicit call to GC.Collect.
In this way my VB.NET program works well, but the same code in an ASP.NET
application doesen't work...
Unfortunately my final application must be an ASP.NET application...
The EXCEL process keeps alive after the applicatoin ends, and also if I
kill asp_net process or restart iis the process keeps alive...

Do you know if I can read the PID of Excel.Application object? If yes I
can kill the process... It's a bad idea, I know, but....

Franx


"Simon Murphy" ha scritto nel messaggio
...
franx
try forcing garbage collection

excelApp = nothing
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
GC.WaitForPendingFinalizers()

This works for me in C# the Vb code wont be far different.
as you say its a die hard process!

cheers
Simon
"Francesco Geri" wrote in message
...
Hi,
I have a VB.NET program that opens an EXCEL workbook. In this program I
modify the workbook, I save it, then I close it.
The code is like this:

Sub mySub()

Dim excelApp As Excel.Application
Dim excelDoc As Excel.Workbook

excelApp = New Excel.Application
excelDoc = excelApp.Workbooks.Open("c:\temp\test.xls")

'code that update the workbook....

excelDoc.Close(True)
excelDoc = Nothing

excelApp.Quit()
excelApp = Nothing

End Sub


I have no errors, but the EXCEL.EXE process keep alive after the
execution.

The EXCEL.EXE process starts on statement:

excelApp = New Excel.Application

and it should die on statement:

excelApp.Quit()


It's right?

Thanks for help!

franx





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing workbooks w/o closing Excel Barb in MD Excel Discussion (Misc queries) 3 February 15th 10 06:42 PM
How to count process running time ( process not finished) miao jie Excel Programming 0 January 13th 05 09:23 AM
How to count process running time ( process not finished) miao jie Excel Programming 2 January 12th 05 06:01 AM
Mail merge issue - ghost Excel process remains after closing application d_b Excel Programming 1 August 16th 04 02:29 PM
Mail merge issue - ghost Excel process remains after closing application d_b Excel Programming 0 August 16th 04 01:12 AM


All times are GMT +1. The time now is 04:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"