473,616 Members | 2,970 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to close EXCEL automation Server in VB?

Hi
I open a Excel workbook using below API:
Set ExcelServer = CreateObject("E XCEL.Applicatio n")
Set TargetWorkbook = ExcelServer.Wor kbooks.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 3030
You are closing your workbook but you are not quitting Excel. Add:
ExcelServer.Qui t
"Wenke Ji" <a1****@motolor a.com> wrote in message
news:04******** *************** *****@phx.gbl.. .
Hi
I open a Excel workbook using below API:
Set ExcelServer = CreateObject("E XCEL.Applicatio n")
Set TargetWorkbook = ExcelServer.Wor kbooks.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 "CreateObje ct" 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****@motolor a.com> wrote in message
news:04******** *************** *****@phx.gbl.. .
Hi
I open a Excel workbook using below API:
Set ExcelServer = CreateObject("E XCEL.Applicatio n")
Set TargetWorkbook = ExcelServer.Wor kbooks.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.Release ComObject(objws )

objxl.Quit()

Marshal.Release ComObject(objxl )

HTH,

Bernie Yaeger

"Wenke Ji" <a1****@motolor a.com> wrote in message
news:04******** *************** *****@phx.gbl.. .
Hi
I open a Excel workbook using below API:
Set ExcelServer = CreateObject("E XCEL.Applicatio n")
Set TargetWorkbook = ExcelServer.Wor kbooks.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(By Val dt As DataTable, ByVal strPath As String,
ByRef pb As ProgressBar, ByVal MyOption As String)

'add reference to Microsoft Excel

Dim objXL As Excel.Applicati on

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.Applicat ion"), Excel.Applicati on)
'create a new instance of Excel if there isn't one running.

'objXL = New Excel.Applicati on

objWBS = objXL.Workbooks

objWB = objWBS.Add

objWS = CType(objWB.Wor ksheets(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.Releas eComObject(objW S)

System.Runtime. InteropServices .Marshal.Releas eComObject(objW B)

System.Runtime. InteropServices .Marshal.Releas eComObject(objW BS)

objXL.Quit()

System.Runtime. InteropServices .Marshal.Releas eComObject(objX L)

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

'http://www.dotnetinter op.com/faq/?q=OfficeCleanu p

'http://support.microso ft.com/default.aspx?sc id=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.WaitForPendi ngFinalizers()

End Sub

--
Joe Fallon

"Bernie Yaeger" <be*****@cherwe llinc.com> wrote in message
news:eK******** ******@TK2MSFTN GP09.phx.gbl...
Hi,

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

objxl.Quit()

Marshal.Release ComObject(objxl )

HTH,

Bernie Yaeger

"Wenke Ji" <a1****@motolor a.com> wrote in message
news:04******** *************** *****@phx.gbl.. .
Hi
I open a Excel workbook using below API:
Set ExcelServer = CreateObject("E XCEL.Applicatio n")
Set TargetWorkbook = ExcelServer.Wor kbooks.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.Release ComObject(Excel Server)




"Wenke Ji" <a1****@motolor a.com> wrote in message
news:04******** *************** *****@phx.gbl.. .
Hi
I open a Excel workbook using below API:
Set ExcelServer = CreateObject("E XCEL.Applicatio n")
Set TargetWorkbook = ExcelServer.Wor kbooks.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
3371
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 ways to read and write Excel files with ADO, but as far as I can tell, it doesn't provide the flexibility I need. I need to be able to generate tabs, cell formatting, formulas, etc.
2
2087
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 manager. If I open a normal application (I.E. Notepad.exe) in the same manner, I have no problem.
3
8365
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 not doing it effectively. If I am debugging my app, and I kill the app before my app exits, but after the call that should close excel, I still have an excell process sitting around. After about 20 + of those stack up, you start to feel it. If I...
9
4423
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 asp.net. The Xl sheet should not be opened in the browser. All the information from dataset(datatable,datarows) should be sent to XL and the file name should be given dynamically through program and the xl file should be saved dynamically through...
6
9341
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 sure it is a permission issue because the script works when I point the browser directly at the .htm file on the c: drive: c:\inetpub\wwwroot\DemoSite\VbScriptTest.htm
8
2175
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 originated in the code. Exception Details: System.UnauthorizedAccessException: Access is denied. ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET...
12
2414
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 and saves it to a folder. The DLL even writes to a log for each step it takes so we can troubleshoot the problems (if any). This works fine on one machine but not another. The folder the DLL is trying to write to has full permissions assigned...
15
5339
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 2003 application (Reports) works ok. But when Office 2003 is upgraded to Office 2007 Excel reports stops working. It Log the error “Exception from HRESULT: 0x800A03EC.” In database.
13
2980
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 me to an example? Do not have Sharepoint. This is for Intranet and security is not important. Thank You
0
8203
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
1
8297
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6097
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5550
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4063
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4141
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2579
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1445
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.