using the code below (some parts not included), I create a new excel
workbook with spreadheets.
I then want to delete a spreadsheet, but a reference remains open and
excel stays in task manager when
the code highlighted below is used. can someone help me identify what
object remains open and
how to release that reference? thanks
using Excel = Microsoft.Offic e.Interop.Excel ;
Excel.Applicati on xl;
Excel.Worksheet sheet;
Excel.Workbooks wbs;
sheets added, etc
//////////////////// reference remains when this code is used
Excel.Workbook wb = xl.ActiveWorkbo ok;
Excel.Worksheet sheet = (Excel.Workshee t)wb.Sheets[1];
////////////////////
xl.Quit();
System.Runtime. InteropServices .Marshal.Releas eComObject(shee t);
sheet = null;
System.Runtime. InteropServices .Marshal.Releas eComObject(wb);
wb = null;
System.Runtime. InteropServices .Marshal.Releas eComObject(wbs) ;
wbs = null;
System.Runtime. InteropServices .Marshal.Releas eComObject(xl);
xl = null;
GC.Collect();
GC.WaitForPendi ngFinalizers(); 3 4843
<pl************ *****@yahoo.com wrote in message
news:11******** *************@e 65g2000hsc.goog legroups.com...
using the code below (some parts not included), I create a new excel
workbook with spreadheets.
I then want to delete a spreadsheet, but a reference remains open and
excel stays in task manager when
the code highlighted below is used. can someone help me identify what
object remains open and
how to release that reference? thanks
using Excel = Microsoft.Offic e.Interop.Excel ;
Excel.Applicati on xl;
Excel.Worksheet sheet;
Excel.Workbooks wbs;
sheets added, etc
//////////////////// reference remains when this code is used
Excel.Workbook wb = xl.ActiveWorkbo ok;
Excel.Worksheet sheet = (Excel.Workshee t)wb.Sheets[1];
////////////////////
xl.Quit();
System.Runtime. InteropServices .Marshal.Releas eComObject(shee t);
sheet = null;
System.Runtime. InteropServices .Marshal.Releas eComObject(wb);
wb = null;
System.Runtime. InteropServices .Marshal.Releas eComObject(wbs) ;
wbs = null;
System.Runtime. InteropServices .Marshal.Releas eComObject(xl);
xl = null;
GC.Collect();
GC.WaitForPendi ngFinalizers();
You already posted the same question before, the answer remains the same, you need to
release all references to Excel objects before you Quit, also, you need to Close the
Workbook before Saving and you need to Save before Quitting.
It really makes no sense to post only part of the code, please post a small but complete
sample that illustrates the issue.
You also have to tell us in what context you are running this code, here I mean, from a
client or from a service like application.
Willy.
On Apr 17, 6:26 pm, "Willy Denoyette [MVP]"
<willy.denoye.. .@telenet.bewro te:
<pleaseexplaint om...@yahoo.com wrote in message
news:11******** *************@e 65g2000hsc.goog legroups.com...
using the code below (some parts not included), I create a new excel
workbook with spreadheets.
I then want to delete a spreadsheet, but a reference remains open and
excel stays in task manager when
the code highlighted below is used. can someone help me identify what
object remains open and
how to release that reference? thanks
using Excel = Microsoft.Offic e.Interop.Excel ;
Excel.Applicati on xl;
Excel.Worksheet sheet;
Excel.Workbooks wbs;
sheets added, etc
//////////////////// reference remains when this code is used
Excel.Workbook wb = xl.ActiveWorkbo ok;
Excel.Worksheet sheet = (Excel.Workshee t)wb.Sheets[1];
////////////////////
xl.Quit();
System.Runtime. InteropServices .Marshal.Releas eComObject(shee t);
sheet = null;
System.Runtime. InteropServices .Marshal.Releas eComObject(wb);
wb = null;
System.Runtime. InteropServices .Marshal.Releas eComObject(wbs) ;
wbs = null;
System.Runtime. InteropServices .Marshal.Releas eComObject(xl);
xl = null;
GC.Collect();
GC.WaitForPendi ngFinalizers();
You already posted the same question before, the answer remains the same, you need to
release all references to Excel objects before you Quit, also, you need to Close the
Workbook before Saving and you need to Save before Quitting.
It really makes no sense to post only part of the code, please post a small but complete
sample that illustrates the issue.
You also have to tell us in what context you are running this code, here I mean, from a
client or from a service like application.
Willy.- Hide quoted text -
- Show quoted text -
sorry I left out this line sheet.Delete();
//////////////////// reference remains when this code is used
Excel.Workbook wb = xl.ActiveWorkbo ok;
Excel.Worksheet sheet = (Excel.Workshee t)wb.Sheets[1];
sheet.Delete();
////////////////////
there are no additional references using wb or sheet in the
application.
is there a (hidden?) reference in these 3 lines that isn't handled
here?
xl.Quit();
System.Runtime. InteropServices .Marshal.Releas eComObject(shee t);
sheet = null;
System.Runtime. InteropServices .Marshal.Releas eComObject(wb);
wb = null;
System.Runtime. InteropServices .Marshal.Releas eComObject(wbs) ;
wbs = null;
System.Runtime. InteropServices .Marshal.Releas eComObject(xl);
xl = null;
GC.Collect();
GC.WaitForPendi ngFinalizers();
and, no this is not the same question that wasn't answered before.
thanks anybody with constructive advice.
<pl************ *****@yahoo.com wrote in message
news:11******** **************@ n76g2000hsh.goo glegroups.com.. .
On Apr 17, 6:26 pm, "Willy Denoyette [MVP]"
<willy.denoye.. .@telenet.bewro te:
><pleaseexplain tom...@yahoo.co mwrote in message
news:11******* **************@ e65g2000hsc.goo glegroups.com.. .
using the code below (some parts not included), I create a new excel
workbook with spreadheets.
I then want to delete a spreadsheet, but a reference remains open and
excel stays in task manager when
the code highlighted below is used. can someone help me identify what
object remains open and
how to release that reference? thanks
using Excel = Microsoft.Offic e.Interop.Excel ;
Excel.Applicati on xl;
Excel.Worksheet sheet;
Excel.Workbooks wbs;
sheets added, etc
//////////////////// reference remains when this code is used
Excel.Workbook wb = xl.ActiveWorkbo ok;
Excel.Worksheet sheet = (Excel.Workshee t)wb.Sheets[1];
////////////////////
xl.Quit();
System.Runtime. InteropServices .Marshal.Releas eComObject(shee t);
sheet = null;
System.Runtime. InteropServices .Marshal.Releas eComObject(wb);
wb = null;
System.Runtime. InteropServices .Marshal.Releas eComObject(wbs) ;
wbs = null;
System.Runtime. InteropServices .Marshal.Releas eComObject(xl);
xl = null;
GC.Collect();
GC.WaitForPendi ngFinalizers();
You already posted the same question before, the answer remains the same, you need to release all references to Excel objects before you Quit, also, you need to Close the Workbook before Saving and you need to Save before Quitting. It really makes no sense to post only part of the code, please post a small but complete sample that illustrates the issue. You also have to tell us in what context you are running this code, here I mean, from a client or from a service like application.
Willy.- Hide quoted text -
- Show quoted text -
sorry I left out this line sheet.Delete();
//////////////////// reference remains when this code is used
Excel.Workbook wb = xl.ActiveWorkbo ok;
Excel.Worksheet sheet = (Excel.Workshee t)wb.Sheets[1];
sheet.Delete();
////////////////////
there are no additional references using wb or sheet in the
application.
is there a (hidden?) reference in these 3 lines that isn't handled
here?
xl.Quit();
System.Runtime. InteropServices .Marshal.Releas eComObject(shee t);
sheet = null;
System.Runtime. InteropServices .Marshal.Releas eComObject(wb);
wb = null;
System.Runtime. InteropServices .Marshal.Releas eComObject(wbs) ;
wbs = null;
System.Runtime. InteropServices .Marshal.Releas eComObject(xl);
xl = null;
GC.Collect();
GC.WaitForPendi ngFinalizers();
and, no this is not the same question that wasn't answered before.
thanks anybody with constructive advice.
Sorry, but you don't come up with a complete sample, how can we answer your question "is
there a (hidden?) reference in these 3 lines that isn't handled here?", if you don't post
the full code or at least a small but complete sample that illustrates the issue.
Also, please answer the question regarding the context and type of this application, is it a
console like a Windows like application, or is it something that runs from a Service? It's
important to answer these, before one can give "constructi ve advise".
Willy. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Allison Bailey |
last post by:
Hi Folks,
I'm a brand new Python programmer, so please point me in the right
direction if this is not the best forum for this question....
I would like to open an existing MS Excel spreadsheet and extract
information from specific worksheets and cells.
I'm not really sure how to get started with this process.
I ran the COM Makepy utility from my PythonWin (IDE from ActiveSTate),
|
by: Otie |
last post by:
I found the following under the GetObject help notes and in the
example for GetObject:
"This example uses the GetObject function to get a reference to a
specific Microsoft Excel worksheet (MyXL). It uses the worksheet's
Application property to make Microsoft Excel visible, to close it, and
so on. Using two API calls, the DetectExcel Sub procedure looks for
Microsoft Excel, and if it is running, enters it in the Running Object
Table. The...
|
by: Vagabond Software |
last post by:
Scenario:
The end-user selects File-Save from my applications (WinForm) menu, specifies a filename, and waits waits for my app to write the contents of a dataset to an Excel workbook. The SaveXLReport method completes successfully, calls myXLClass.Dispose, and returns control to the user form at a base state.
At this point, there is still an EXCEL.EXE in processes and the specified workbook cannot be saved until that process is ended from...
|
by: Tim Marsden |
last post by:
Hi,
I have a routine which is call from a ASP.NET web form. This routine creates
an excel application, opens a workbook , runs some code to update the
workbook, saves it as HTML on the sever and returns to the Web form to
display.
All is OK, except EXCEL remains in the process list in task manager.
I am following all guideline in releasing the com components.
|
by: Praveen K |
last post by:
I have a problem in communicating between the C# and the Excel Interop
objects. The problem is something as described below.
I use Microsoft Office-XP PIA dll’s as these dll’s were been recommended by
many for web applications. I create the instances of Excel, Workbook and the
worksheet. And later on Release the references by
“System.Runtime.InteropServices.Marshal.ReleaseComObject(Object)” and making
the object as null finally....
| |
by: rhett |
last post by:
howdy folks,
first off, I'd like to not that I have browsed the forums and thanks to
what I've found there I'm 80% through this problem, but the last part
seems to be a profound obstacle and any help you could provide would be
much appreciated.
As my title indicates, I'm devloping a C# application which will need
to opne up an excel template...manipulate and save it, and then quit.
The problem I'm having is that the instance of...
|
by: garry.oxnard |
last post by:
Can anyone help me to solve a problem which involves switching from
Access to Excel (then back to Access) programatically please?
I have an Excel template which, on open, also opens an Access database
- containing a list of addresses.
Sequence of events is =
(1) Excel template opens in its default XXX.xls filename.
(2) Code runs to save the spreadsheet as XXX.xls.
(3) User clicks a button to open an Access database containing an
|
by: blainegray |
last post by:
Greetings
This is one of those Access is not closing Excel problems.
The first time through the code works fine. The second time there is a problem.
After lots of combinations, I finally determined that if I take out the line that copies the temp array to cells in a worksheet, Access will close the Excel file. If the line is there, Excel remains open and blocks more runs of the same procedure. If I close Access, Excel gets closed. Looks like...
|
by: =?Utf-8?B?VGVycnkgSG9sbGFuZA==?= |
last post by:
I have a vb.net app that opens an excel worksheet, reads data and then closes
the sheet. Im noticing that the Excel process is still running after I have
closed and disposed of my excel objects.
The following code (Test1) demonstrates the essence of what I am doing.
When I check the processes while ruinning the method, I notice that the Excel
process remains after exiting the sub (and until I exit the application)
Sub Test1
Dim...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
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...
|
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 projectplanning, coding, testing, and deploymentwithout 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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |