Solved

Why EXCEL wont Close after use in vb.net

Posted on 2007-03-21
3
318 Views
Last Modified: 2012-05-05
xls will not stop/end after use in vb.net
       
 
 
 I have asked this question before but still no answers.

I have an application (vb.net 2005) that use the following I then need to delete after it is finished doing what I am doing.. but I keep getting an error that it is still in use. and when I look at task manager processes there is still an excel app running, even though it is not in the current tasks.

PLEASE HELP HOW DO I REMOVE THE EXCEL FROM THE PROCESS!!!!!!!!!!!!

Imports VBIDE = Microsoft.Vbe.Interop

Imports Microsoft.Office.Core

Dim xlsApp As Excel.Application

Dim xlsWB As Excel.Workbook

Dim xlsSheet As Excel.Worksheet

Dim xlsCell As Excel.Range

xlsApp = New Excel.Application

xlsWB = xlsApp.Workbooks.Open(c:test.xls)

xlsSheet = xlsWB.Worksheets(1)

xlsCell = xlsSheet.Range("A1")

xlsWB.Close()

xlsApp.Quit()

System.Runtime.InteropServices.Marshal.ReleaseComObject(xlsSheet)

System.Runtime.InteropServices.Marshal.ReleaseComObject(xlsWB)

System.Runtime.InteropServices.Marshal.ReleaseComObject(xlsApp)

xlsWB = Nothing

xlsApp = Nothing

xlsSheet = Nothing

GC.Collect()

GC.WaitForPendingFinalizers()

GC.Collect()

GC.WaitForPendingFinalizers()
 
 
 
0
Comment
Question by:LeeHopkins
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
bhagavan2uday earned 125 total points
ID: 18769236
have closed the sheet also
0
 
LVL 21

Expert Comment

by:theGhost_k8
ID: 18769500
I hope this is Typo:-...Open(c:test.xls) <--  no "\"
you have to release all this objects

Dim xlsApp As Excel.Application
Dim xlsWB As Excel.Workbook
Dim xlsSheet As Excel.Worksheet
Dim xlsCell As Excel.Range

I believe you missed the last one.
0
 
LVL 21

Expert Comment

by:theGhost_k8
ID: 18777498
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlsCell )
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question