?
Solved

Why EXCEL wont Close after use in vb.net

Posted on 2007-03-21
3
Medium Priority
?
321 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 500 total points
ID: 18769236
have closed the sheet also
0
 
LVL 21

Expert Comment

by:K V
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:K V
ID: 18777498
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlsCell )
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

762 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