473,320 Members | 2,088 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,320 software developers and data experts.

Close a running application

I have a program that updates an Excel sheet everytime
the user presses a button. However, each time it creates
a new instance of the Excel.exe application running in
the background.
I tried closing my Excel object (oExcel) using the
following:
oExcel = Nothing
oExcel.quit()

Yet, I still can see an instance of Excel.exe in the
Windows Task Manager Processes.

Any idea on how to force this application to terminate
once I'm done with it?

Note1: I define the Excel object using:

Dim oExcel As Excel.Application
oExcel = CType(CreateObject("Excel.Application"), _
Excel.Application)

Note2: When I end my program, that instance of Excel
disappears. I wish to see that without leaving my program.
Nov 20 '05 #1
4 1870
Hi,

Marshal.ReleaseComObject(oExcel)

Ken
-----------
"Amjad" <am*********@hotmail.com> wrote in message
news:04****************************@phx.gbl...
I have a program that updates an Excel sheet everytime
the user presses a button. However, each time it creates
a new instance of the Excel.exe application running in
the background.
I tried closing my Excel object (oExcel) using the
following:
oExcel = Nothing
oExcel.quit()

Yet, I still can see an instance of Excel.exe in the
Windows Task Manager Processes.

Any idea on how to force this application to terminate
once I'm done with it?

Note1: I define the Excel object using:

Dim oExcel As Excel.Application
oExcel = CType(CreateObject("Excel.Application"), _
Excel.Application)

Note2: When I end my program, that instance of Excel
disappears. I wish to see that without leaving my program.

Nov 20 '05 #2
* "Amjad" <am*********@hotmail.com> scripsit:
I have a program that updates an Excel sheet everytime
the user presses a button. However, each time it creates
a new instance of the Excel.exe application running in
the background.
I tried closing my Excel object (oExcel) using the
following:
oExcel = Nothing
oExcel.quit()

Yet, I still can see an instance of Excel.exe in the
Windows Task Manager Processes.

Any idea on how to force this application to terminate
once I'm done with it?

Note1: I define the Excel object using:

Dim oExcel As Excel.Application
oExcel = CType(CreateObject("Excel.Application"), _
Excel.Application)

Note2: When I end my program, that instance of Excel
disappears. I wish to see that without leaving my program.


\\\
System.Runtime.InteropServices.Marshal.ReleaseComO bject(App)
App = Nothing

' Perhaps you need these lines too:
GC.Collect()
GC.WaitForPendingFinalizers()
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
Hi..
Thanks for your reply, but the problem hasn't been solved
yet! (Excel.exe is still running in the background)
Any other suggestions?

Amjad
-----Original Message-----
* "Amjad" <am*********@hotmail.com> scripsit:
I have a program that updates an Excel sheet everytime
the user presses a button. However, each time it creates a new instance of the Excel.exe application running in
the background.
I tried closing my Excel object (oExcel) using the
following:
oExcel = Nothing
oExcel.quit()

Yet, I still can see an instance of Excel.exe in the
Windows Task Manager Processes.

Any idea on how to force this application to terminate
once I'm done with it?

Note1: I define the Excel object using:

Dim oExcel As Excel.Application
oExcel = CType(CreateObject("Excel.Application"), _
Excel.Application)

Note2: When I end my program, that instance of Excel
disappears. I wish to see that without leaving my
program.
\\\
System.Runtime.InteropServices.Marshal.ReleaseCom Object (App)App = Nothing

' Perhaps you need these lines too:
GC.Collect()
GC.WaitForPendingFinalizers()
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
.

Nov 20 '05 #4
Hi Amjad,

You may have to do the same sort of releasing on <all> of the Excel
objects that you create.

Next year's .NET will include better Office integration. Perhaps they will
have addressed this issue.

In the meantime, the interop newsgroup is possibly the best place for this
question as they must have been asked it a hundred times for Excel and all the
other Office products.
news://msnews.microsoft.com/microsof...mework.interop

Regards,
Fergus
Nov 20 '05 #5

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

Similar topics

1
by: Gary Cobden | last post by:
Hi I have a routine that uses VBA to open a hidden occurence of Excel, and do background computations. However, in the event that the routine terminates abnormally, I have not been able to...
14
by: vbMark | last post by:
First this runs: static void Main() { ///////////////////// /// Don't let app run more than one instance. /// Process aProcess = Process.GetCurrentProcess();
1
by: Alpha | last post by:
I have a Window based application that shows up still running in the task manager when I close it. It reaches the "this.close" statement and then it stops at the "}" at the section of the...
5
by: Wenke Ji | last post by:
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...
8
by: Greg Strong | last post by:
Hello All, The short questions are 1 Do you know how to make DSN connection close in Access to Oracle 10g Express Edition? &/or 2 Do you know how to make a DSN-less pass-through query...
4
by: Jason Huang | last post by:
Hi, In my C# windows form project, how do I in a formA open another formB, and close formA when formB is opened? Thanks for help. Jason
0
by: Mark Gold | last post by:
Hi! We have a VB application using Crystal Reports 6 that has worked successfully on hundreds of systems for over 10 years. Now, on one network, the application and access database does not close....
0
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of...
5
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of...
2
by: Bassem | last post by:
I'm working on simple chat program via serial port. It works fine, but i face this problem. When i try to open the exe, UnauthorizedAccess exception occurs, i can't use COM1 becuase someone else has...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.