Solved

Why EXCEL wont Close after use in vb.net

Posted on 2007-03-21
3
317 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET 2008 - Windows Protected Your PC 7 52
Expression Evaluater 3 45
Get distinct values from excel or comm seperated file 4 40
Optimize the query 5 52
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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