473,800 Members | 2,385 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Excel Interop problem

Hello,

I am using Excel Interop to export data from a dataset to an excel-file.
Everything works fine except closing the excel-file.

I have an Application-object and a Workbook-object. I call the Close
method on the Workbook en the Quit on the Application.

My program works fine but after my program is closed, I can still see
Excel running as a process on my pc, this gives troubles when shutting
down the pc.

Anyone who has an idea?

Thanks,
Dries
Jan 7 '06 #1
4 1682
hi Dries,

well i think in ur case u can use
System.Runtime. InteropServices .Marshal.Releas eComObject()

this method to release the COM object whenever you close the
application which should Dispose the EXCEL application object.

call it in your form closing event when u finish working with EXCEL
application object and run this loop in the event. pass your EXCEL
Application object to the method.

While System.Runtime. InteropServices .Marshal.Releas eComObject("Exc el
Application Object") = 0
End While

Jan 7 '06 #2
hi Dries,

well i think in ur case u can use
System.Runtime. InteropServices .Marshal.Releas eComObject()

this method to release the COM object whenever you close the
application which should Dispose the EXCEL application object.

call it in your form closing event when u finish working with EXCEL
application object and run this loop in the event. pass your EXCEL
Application object to the method.

While System.Runtime. InteropServices .Marshal.Releas eComObject("Exc el
Application Object") = 0
End While

Jan 7 '06 #3
Lucky wrote:
hi Dries,

well i think in ur case u can use
System.Runtime. InteropServices .Marshal.Releas eComObject()

this method to release the COM object whenever you close the
application which should Dispose the EXCEL application object.

call it in your form closing event when u finish working with EXCEL
application object and run this loop in the event. pass your EXCEL
Application object to the method.

While System.Runtime. InteropServices .Marshal.Releas eComObject("Exc el
Application Object") = 0
End While

thanks, it works
Jan 7 '06 #4
That's really only a partial solution. See
http://support.microsoft.com/default...;EN-US;q317109 for an
explanation.

Use the following:

Private Sub NAR(ByVal o As Object)

Dim refCount As Int32

Try

Do

refCount = System.Runtime. InteropServices .Marshal.Releas eComObject(o)

Loop While refCount > 0

Catch

Finally

o = Nothing

End Try

End Sub

"Lucky" <tu************ @gmail.com> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com.. .
hi Dries,

well i think in ur case u can use
System.Runtime. InteropServices .Marshal.Releas eComObject()

this method to release the COM object whenever you close the
application which should Dispose the EXCEL application object.

call it in your form closing event when u finish working with EXCEL
application object and run this loop in the event. pass your EXCEL
Application object to the method.

While System.Runtime. InteropServices .Marshal.Releas eComObject("Exc el
Application Object") = 0
End While

Jan 8 '06 #5

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

Similar topics

17
6348
by: Mansi | last post by:
I need to do some research on how to use excel automation from c#. Does anyone know of any good books related to this subject? Thanks. Mansi
1
3042
by: Bernd Muent | last post by:
Hi together, I am using the following code in Visual Basic to open Word or Excel applications: Word: Dim w As Word.Application w = CType(CreateObject("Word.application"), Word.Application) w.Application.Documents.Open("test.doc") With w.Application.Selection
2
2094
by: Hans Wien | last post by:
I have to write a lot of data to excel for analysts who use it further from there but would like to use managed C++ and not C# since a lot of code is involved which already exists now in managed C++. In C# I could handle it easily as you can see in this sample: using Excel = Microsoft.Office.Interop.Excel; .... private Excel.Application thisApplication; private Excel.Workbook myWorkbook1;
4
3127
by: goonsquad | last post by:
I'm writing an Excel Automation app and I'm running to a problem early on with what should be a basic step. Dim oExcel As Object Dim oBook As Object Dim oSheet As Object Dim oRng As Excel.Range oExcel = CreateObject("Excel.Application") oBook = oExcel.Workbooks.Add oSheet = oBook.Worksheets(1)
3
10751
by: James Wong | last post by:
Dear all, I have an old VB6 application which can create and access Excel object. The basic definition statements are as follows: Dim appExcel As Object Dim wkb1 As Excel.Workbook Dim wks1 As Excel.Worksheet Set appExcel = New
2
10060
by: jereviscious | last post by:
Hi all - Last resort time. I'm importing data from a spreadsheet that I receive from one of my vendor using interop.excel. The date field in excel is entered as 4/7/2006, but when I retrieve the value, it returns a double 38449.0. I can't figure out how to convert this value into a proper date. I have no Idea what excel is doing with this date. Also, when I enter in 38449 into
0
2759
by: liam_jones | last post by:
I'm very new to Python, well IronPython to precise, and have been having problems when using Excel. The problem I'm having is the closing of my Excel object. I'm able to successfully quit the Excel Application that I create, but when I open a Workbook in the Application I can't successfully Quit Excel (by this I mean I can quit it, but the Excel process isn't getting killed and I have to manually go this through Task Manager). I've...
3
2214
by: KaNos | last post by:
Hello, I'm programming an C# application which uses Automation. The problem is when I quit the application a ghost of excel is always running (Can be seen in all processes with th task manager). What is the solution ? Thanks
2
4928
by: Nicholas Dreyer | last post by:
The following error Run-time exception thrown : System.Runtime.InteropServices.COMException - Error loading type library/DLL. happens while running the code listed at the bottom of this message in the environment shown here: Operating System: Microsoft Windows Version 5.1 (Build
0
2711
by: jwmaiden | last post by:
Have an application that opens up a webbrowser control to display data in an Excel spreadsheet (using VB.NET in VS 2005). No problem with opening the spreadsheet or displaying the data, but I'm having problems with repeating the process. I want to create an Excel spreadsheet, add some data to it, and display the results in a webbrowser control. I want to be able to then later delete the old Excel spreadsheet, create a new one, add some new data,...
0
9690
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10275
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10033
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...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7576
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
6811
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
5471
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
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
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

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.