Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel don't quit in ASP.net Code

Hi!

I am unable to close my Excel-Task in the following
ASP.net Code:

oMissing = System.Reflection.Missing.Value
objXL = Server.CreateObject("Excel.Application")

objWB = objXL.WorkBooks.add("AuslastungAuftrag.xlt")
objBooks = objXL.Workbooks
objWS = objWB.Worksheets(1) 'i need it for Range-Operations

objXL.visible = False
objXL.Cells(2, 1).Value = "this"
objXL.Cells(2, 2).Value = "is"
objXL.Cells(2, 3).Value = "a test"

objWB.SaveAs(Me.sPathReports & sFileName)

'Closing and to releasing the Com-Objects
While
(System.Runtime.InteropServices.Marshal.ReleaseCom Object
(objWS) < 0)
End While

objWS = Nothing
objWB.Close(False, oMissing, oMissing)

While
(System.Runtime.InteropServices.Marshal.ReleaseCom Object
(objWB) < 0)
End While

objWB = Nothing

While
(System.Runtime.InteropServices.Marshal.ReleaseCom Object
(objBooks) < 0)
End While
objBooks = Nothing

objXL.Quit()

While
(System.Runtime.InteropServices.Marshal.ReleaseCom Object
(objXL) < 0)
End While
objXL = Nothing

'Garbage Collection
GC.Collect()
System.GC.WaitForPendingFinalizers()


After calling this Code 5-times, 4 Excel Processes will be
closed and one is still remaining.
Without the "ReleaseComObject"-Call none of the processes
will be closed.

BUT: Sometime it works properly. Yesterday it worked fine -
then i added some ADO-Code to fill the Excel-Table with
SQL-Data. After this i became the problem. Is it
magic.... :-)

Any Idea?
Thx, Andreas

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
Excel quit opening amber_verstraete Excel Discussion (Misc queries) 4 September 19th 07 06:44 PM
can't quit excel maven Excel Discussion (Misc queries) 0 March 15th 07 12:31 AM
Excel won't quit JRS Excel Discussion (Misc queries) 1 September 27th 05 04:31 AM
Can't get Excel to quit Todd Waldron Excel Programming 10 November 22nd 03 03:19 PM
Excel won't quit Jeff[_23_] Excel Programming 0 October 24th 03 05:14 PM


All times are GMT +1. The time now is 08:21 AM.

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

About Us

"It's about Microsoft Excel"