Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / April 2004

Tip: Looking for answers? Try searching our database.

Cannot terminate an excel process using VB.NET

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Anthony Terra - 06 Apr 2004 18:14 GMT
I hope someone can help me with this.

I am opening an excel object using the:
_XlApp = GetObject(, "excel.Application")
syntax.  Excel, itself, is being called from a browser control.

I have tried microsofts suggestion
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B317109 to
no avail.

If anyone knows of anyway to terminate the excel process under these
circumstances, please help.

Thank You,

Anthony Terra

Senior Software Engineer
Paul Clement - 06 Apr 2004 20:38 GMT
¤ I hope someone can help me with this.
¤
¤ I am opening an excel object using the:
¤  _XlApp = GetObject(, "excel.Application")
¤ syntax.  Excel, itself, is being called from a browser control.
¤
¤ I have tried microsofts suggestion
¤ http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B317109 to
¤ no avail.
¤
¤ If anyone knows of anyway to terminate the excel process under these
¤ circumstances, please help.

Are you creating any implicit Excel objects? This usually occurs when you create a new application
object but don't set it to an object variable so that it can be destroyed.

You may want to post a bit more code so we can see what you are doing.

Paul ~~~ pclement@ameritech.net
Microsoft MVP (Visual Basic)
Gavin Jacobs - 08 Apr 2004 21:52 GMT
I am having a similar problem. Here is my code:

  Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
       ' Put user code to initialize the page here
       ' Excel stuff
       ' Resist the temptation to use an Office 10 reference; webserver6
has Excel 5!
       Dim obExcelApp As Object
       Dim obWorkBook As Object
       Dim obWorkBooks As Object
       Dim obWorkSheets As Object
       Dim obWorkSheet As Object
       Dim inRow As Short
       Dim strRangeLast, strRangeFirst, strRangeDate, strRangeMethod
<snip>
       ' Open the file
       Try
           obExcelApp = Interaction.CreateObject("Excel.Application")
           Try
               obWorkBooks = obExcelApp.Workbooks
               obWorkBook = obWorkBooks.Open("M:\Travel\blah.xls")
               obWorkSheets = obWorkBook.worksheets
               obWorkSheet = obWorksheets.Item("blah")
               Dim bDone As Boolean = False
               For inRow = 3 To 99
  <snip>
               Next
               If Not bDone Then
                   txtStatus.Text += "File is too large!" & vbCrLf
               End If
               obWorkBook.Close()
           Catch ex As Exception
               txtStatus.Text += "Can't open file!" & vbCrLf
               txtStatus.Text += ex.Message & vbCrLf
           End Try
           NAR(obWorkSheet)
           NAR(obWorkSheets)
           NAR(obWorkBook)
           NAR(obWorkBooks)
           obExcelApp.quit()
       Catch ex As Exception
           txtStatus.Text += "Can't start Excel!" & vbCrLf
           txtStatus.Text += ex.Message & vbCrLf
       End Try
       NAR(obExcelApp)
       GC.Collect()
   End Sub

   ' COM object destroyer - see KB317109
   Private Sub NAR(ByVal o As Object)
       Try
           System.Runtime.InteropServices.Marshal.ReleaseComObject(o)
       Catch
       Finally
           o = Nothing
       End Try
   End Sub

> I hope someone can help me with this.
>
[quoted text clipped - 14 lines]
>
> Senior Software Engineer
John Murray - 08 Apr 2004 23:58 GMT
May not work, but I have had some luck with this, add the following:

GC.WaitForPendingFinalizers();

after your call to GC.Collect()

"Gavin Jacobs" <notachance@inhell.net> wrote in news:eyVv7taHEHA.828
@TK2MSFTNGP12.phx.gbl:

> I am having a similar problem. Here is my code:

<snip>
>         NAR(obExcelApp)
>         GC.Collect()
>     End Sub
<snip
Santhosh Pillai [MS] - 09 Apr 2004 07:19 GMT
This code works for me from a VB.NET application.
You should keep in mind that Microsoft does not recommend or support
server-side Automation of Office.
http://support.microsoft.com/default.aspx?scid=kb;EN-US;257757

> I am having a similar problem. Here is my code:
>
[quoted text clipped - 73 lines]
> >
> > Senior Software Engineer

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.