473,387 Members | 1,611 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to close EXCEL automation Server in VB?

Hi
I open a Excel workbook using below API:
Set ExcelServer = CreateObject("EXCEL.Application")
Set TargetWorkbook = ExcelServer.Workbooks.Open
(CurrentBook)

Befor the programm exit , I use the below API:
TargetWorkbook.Save
TargetWorkbook.Close

But I check the "Task Management" , the Excel is still at
list.
How can I close the EXCEL automation server completely in
VB program?
Thanks!

BRs
Wenke
Nov 20 '05 #1
5 3021
You are closing your workbook but you are not quitting Excel. Add:
ExcelServer.Quit
"Wenke Ji" <a1****@motolora.com> wrote in message
news:04****************************@phx.gbl...
Hi
I open a Excel workbook using below API:
Set ExcelServer = CreateObject("EXCEL.Application")
Set TargetWorkbook = ExcelServer.Workbooks.Open
(CurrentBook)

Befor the programm exit , I use the below API:
TargetWorkbook.Save
TargetWorkbook.Close

But I check the "Task Management" , the Excel is still at
list.
How can I close the EXCEL automation server completely in
VB program?
Thanks!

BRs
Wenke

Nov 20 '05 #2
Don't use the "CreateObject" command. Use the Excel Automation model
instead, and then call .Quit() on the Excel instance when you're done.

http://support.microsoft.com/default...NoWebContent=1
"Wenke Ji" <a1****@motolora.com> wrote in message
news:04****************************@phx.gbl...
Hi
I open a Excel workbook using below API:
Set ExcelServer = CreateObject("EXCEL.Application")
Set TargetWorkbook = ExcelServer.Workbooks.Open
(CurrentBook)

Befor the programm exit , I use the below API:
TargetWorkbook.Save
TargetWorkbook.Close

But I check the "Task Management" , the Excel is still at
list.
How can I close the EXCEL automation server completely in
VB program?
Thanks!

BRs
Wenke

Nov 20 '05 #3
Hi,

Use this around your .quit code:
Marshal.ReleaseComObject(objws)

objxl.Quit()

Marshal.ReleaseComObject(objxl)

HTH,

Bernie Yaeger

"Wenke Ji" <a1****@motolora.com> wrote in message
news:04****************************@phx.gbl...
Hi
I open a Excel workbook using below API:
Set ExcelServer = CreateObject("EXCEL.Application")
Set TargetWorkbook = ExcelServer.Workbooks.Open
(CurrentBook)

Befor the programm exit , I use the below API:
TargetWorkbook.Save
TargetWorkbook.Close

But I check the "Task Management" , the Excel is still at
list.
How can I close the EXCEL automation server completely in
VB program?
Thanks!

BRs
Wenke

Nov 20 '05 #4
I have the same problem.
I have tried lots of things and just couldn't get it to quit.
I think one of my references may not be the correct style and is forcing
Excel to stay open but for the life of me I can't see it.

Anyone want to try?

Public Sub Export2Excel(ByVal dt As DataTable, ByVal strPath As String,
ByRef pb As ProgressBar, ByVal MyOption As String)

'add reference to Microsoft Excel

Dim objXL As Excel.Application

Dim objWBS As Excel.Workbooks

Dim objWB As Excel.Workbook

Dim objWS As Excel.Worksheet

'get a running instance of Excel - this minimizes the number of instances of
Excel in memory!

objXL = CType(GetObject(, "Excel.Application"), Excel.Application)
'create a new instance of Excel if there isn't one running.

'objXL = New Excel.Application

objWBS = objXL.Workbooks

objWB = objWBS.Add

objWS = CType(objWB.Worksheets(1), Excel.Worksheet)

'do stuff here

objWB.Close()

'problem - Excel is staying in Memory even after the Quit. It goes
away when the form is closed.

'Limited to 1 instance stuck in memory instead of unlimited number.

System.Runtime.InteropServices.Marshal.ReleaseComO bject(objWS)

System.Runtime.InteropServices.Marshal.ReleaseComO bject(objWB)

System.Runtime.InteropServices.Marshal.ReleaseComO bject(objWBS)

objXL.Quit()

System.Runtime.InteropServices.Marshal.ReleaseComO bject(objXL)

'this does not work to clear out the Excel instance from memory. Even though
it looks like "just the thing".

'http://www.dotnetinterop.com/faq/?q=OfficeCleanup

'http://support.microsoft.com/default.aspx?scid=kb;en-us;317109

'release other objects too! Still does not work. May be the remote call
issue.

objWS = Nothing

objWB = Nothing

objWBS = Nothing

objXL = Nothing

'this does not work to clear out the Excel instance from memory either.

GC.Collect()

GC.WaitForPendingFinalizers()

End Sub

--
Joe Fallon

"Bernie Yaeger" <be*****@cherwellinc.com> wrote in message
news:eK**************@TK2MSFTNGP09.phx.gbl...
Hi,

Use this around your .quit code:
Marshal.ReleaseComObject(objws)

objxl.Quit()

Marshal.ReleaseComObject(objxl)

HTH,

Bernie Yaeger

"Wenke Ji" <a1****@motolora.com> wrote in message
news:04****************************@phx.gbl...
Hi
I open a Excel workbook using below API:
Set ExcelServer = CreateObject("EXCEL.Application")
Set TargetWorkbook = ExcelServer.Workbooks.Open
(CurrentBook)

Befor the programm exit , I use the below API:
TargetWorkbook.Save
TargetWorkbook.Close

But I check the "Task Management" , the Excel is still at
list.
How can I close the EXCEL automation server completely in
VB program?
Thanks!

BRs
Wenke


Nov 20 '05 #5
Won't this work?

Marshal.ReleaseComObject(ExcelServer)




"Wenke Ji" <a1****@motolora.com> wrote in message
news:04****************************@phx.gbl...
Hi
I open a Excel workbook using below API:
Set ExcelServer = CreateObject("EXCEL.Application")
Set TargetWorkbook = ExcelServer.Workbooks.Open
(CurrentBook)

Befor the programm exit , I use the below API:
TargetWorkbook.Save
TargetWorkbook.Close

But I check the "Task Management" , the Excel is still at
list.
How can I close the EXCEL automation server completely in
VB program?
Thanks!

BRs
Wenke

Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Guy Incognito | last post by:
Hello, I've written an asp.net application that creates Excel documents. It works by creating an excel document in XML format. But I wonder if I'm reinventing the wheel. I know that there are...
2
by: Lorenzo Melato | last post by:
Hi everyone, I have a very strange problem. If I open a .NET application from EXCEL using SHELL function, when I close EXCEL, the EXCEL.EXE process remain active and I must close it by Task...
3
by: David Berman | last post by:
Hi, I've written an application to do a while bunch of Excel automation. I open a file, scan through all the worksheets, extract data, and then I try to close Excel. However, I can see that I'm...
9
by: hari krishna | last post by:
hi, I want to send the data from dataset information to Excel through ASP.Net. there will be no XL installed on web server. web server is win 2000 server machine. I am using visual basic code in...
6
by: Steve Richter | last post by:
I am getting error in a vbscript: ActiveX component cant create object: Excel.Application. The vbscript code is: Dim objExcel Set objExcel = CreateObject("Excel.Application") I am pretty...
8
by: jack | last post by:
Access is denied. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it...
12
by: D. Shane Fowlkes | last post by:
This most likely belongs in another forum but I thought I'd start here. I have a COM Object written in VB6. The DLL will access MS Excel and use it's Object Library to write a customized report...
15
by: =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?= | last post by:
Hi All, We are in the process of Upgrade Excel 2003 (Office 2003) to Excel 2007 (Office 2007) for one of web application. This web application is using Excel (Pivot Table) reports. With Excel...
13
by: Peter | last post by:
VS2008 ans ASP.NET 3.5, Office 2003 What is the best way to run Excel Template from ASP.NET web page were the Excel is only installed on the client without any ActiveX? If so can someone point...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.