473,378 Members | 1,378 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,378 software developers and data experts.

VB2005 problem with Excel

A VB2003 application upgraded to VB2005 that builds an Excel spreadsheet.
Everything appears to work correctly except that the Excel object does not go
away it is still in the Process list in task manager.

This problem did not exist in the VB2003 version.

Are there a any ideas of what might be happening?

All of the Excel objects are being disposed of by setting them to Nothing
and the Quit method is called for Excel. I've even used the
System.Runtime.InteropServices.Marshal.ReleaseComO bject method as well as the
WaitForPendingFinalizers method and nothing seems to effect this.

At the applications END statement an error shows of "ObjectDisposedException
was not handled".

Nov 23 '05 #1
6 2271
I suppose that you have already read and applied:

Office application does not quit after automation from Visual Studio .NET
client
http://support.microsoft.com/default...b;en-us;317109

So, I would recommend to remove statements that manipulate Excel until you
find the culprit. In other words, post a minimal sample to reproduce the
problem, so other people can take a look.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"Darrell Wesley" <Da***********@discussions.microsoft.com> escribió en el
mensaje news:96**********************************@microsof t.com...
A VB2003 application upgraded to VB2005 that builds an Excel spreadsheet.
Everything appears to work correctly except that the Excel object does not
go
away it is still in the Process list in task manager.

This problem did not exist in the VB2003 version.

Are there a any ideas of what might be happening?

All of the Excel objects are being disposed of by setting them to Nothing
and the Quit method is called for Excel. I've even used the
System.Runtime.InteropServices.Marshal.ReleaseComO bject method as well as
the
WaitForPendingFinalizers method and nothing seems to effect this.

At the applications END statement an error shows of
"ObjectDisposedException
was not handled".

Nov 23 '05 #2
I've found out by experimenting around that Excel was not going away due to
a secondary problem I'm having with the IBM iSeries .net data provider.

Changing the application to use the ODBC provider resolved the Excel issue.

Now it's just a matter of waiting for IBM to provide an update to their .net
data provider for the iSeries machine.

"Carlos J. Quintero [VB MVP]" wrote:
I suppose that you have already read and applied:

Office application does not quit after automation from Visual Studio .NET
client
http://support.microsoft.com/default...b;en-us;317109

So, I would recommend to remove statements that manipulate Excel until you
find the culprit. In other words, post a minimal sample to reproduce the
problem, so other people can take a look.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"Darrell Wesley" <Da***********@discussions.microsoft.com> escribió en el
mensaje news:96**********************************@microsof t.com...
A VB2003 application upgraded to VB2005 that builds an Excel spreadsheet.
Everything appears to work correctly except that the Excel object does not
go
away it is still in the Process list in task manager.

This problem did not exist in the VB2003 version.

Are there a any ideas of what might be happening?

All of the Excel objects are being disposed of by setting them to Nothing
and the Quit method is called for Excel. I've even used the
System.Runtime.InteropServices.Marshal.ReleaseComO bject method as well as
the
WaitForPendingFinalizers method and nothing seems to effect this.

At the applications END statement an error shows of
"ObjectDisposedException
was not handled".


Nov 23 '05 #3
Carlos,

Even though I've resolved part of the problem I find that Excel does not
disappear from the Process list until the application terminates.

This is not a particular problem for this specific application but it would
be for others especailly the ones that tend to remain open on the desktop for
most of the day and Excel is used for a reporting tool.

Here's the sample code.

Imports Excel
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim objexcel As Excel.Application
Dim xlWB As Excel.Workbook
Dim xlWS As Excel.Worksheet
objexcel = New Excel.Application
xlWB = objexcel.Workbooks.Add
xlWS = xlWB.Sheets("Sheet1")
xlWS.Select()
System.Runtime.InteropServices.Marshal.ReleaseComO bject(xlWS)
xlWS = Nothing
xlWB.Close()
System.Runtime.InteropServices.Marshal.ReleaseComO bject(xlWB)
xlWB = Nothing
objexcel.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComO bject(objexcel)
objexcel = Nothing

End Sub
End Class

One other thing I'm using Excel 2000 the Object Library version 9.
"Carlos J. Quintero [VB MVP]" wrote:
I suppose that you have already read and applied:

Office application does not quit after automation from Visual Studio .NET
client
http://support.microsoft.com/default...b;en-us;317109

So, I would recommend to remove statements that manipulate Excel until you
find the culprit. In other words, post a minimal sample to reproduce the
problem, so other people can take a look.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"Darrell Wesley" <Da***********@discussions.microsoft.com> escribió en el
mensaje news:96**********************************@microsof t.com...
A VB2003 application upgraded to VB2005 that builds an Excel spreadsheet.
Everything appears to work correctly except that the Excel object does not
go
away it is still in the Process list in task manager.

This problem did not exist in the VB2003 version.

Are there a any ideas of what might be happening?

All of the Excel objects are being disposed of by setting them to Nothing
and the Quit method is called for Excel. I've even used the
System.Runtime.InteropServices.Marshal.ReleaseComO bject method as well as
the
WaitForPendingFinalizers method and nothing seems to effect this.

At the applications END statement an error shows of
"ObjectDisposedException
was not handled".


Nov 23 '05 #4
Hi Darrell ,

In your sample code neither objexcel.Workbooks nor xlWB.Sheets are using a
explicit variable that is released explicitly later, so Excel will stay
alive...

Please read again CAREFULLY the article that I mentioned, the Resolution
section...

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"Darrell Wesley" <Da***********@discussions.microsoft.com> escribió en el
mensaje news:49**********************************@microsof t.com...
Carlos,

Even though I've resolved part of the problem I find that Excel does not
disappear from the Process list until the application terminates.

This is not a particular problem for this specific application but it
would
be for others especailly the ones that tend to remain open on the desktop
for
most of the day and Excel is used for a reporting tool.

Here's the sample code.

Imports Excel
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim objexcel As Excel.Application
Dim xlWB As Excel.Workbook
Dim xlWS As Excel.Worksheet
objexcel = New Excel.Application
xlWB = objexcel.Workbooks.Add
xlWS = xlWB.Sheets("Sheet1")
xlWS.Select()
System.Runtime.InteropServices.Marshal.ReleaseComO bject(xlWS)
xlWS = Nothing
xlWB.Close()
System.Runtime.InteropServices.Marshal.ReleaseComO bject(xlWB)
xlWB = Nothing
objexcel.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComO bject(objexcel)
objexcel = Nothing

End Sub
End Class

One other thing I'm using Excel 2000 the Object Library version 9.
"Carlos J. Quintero [VB MVP]" wrote:
I suppose that you have already read and applied:

Office application does not quit after automation from Visual Studio .NET
client
http://support.microsoft.com/default...b;en-us;317109

So, I would recommend to remove statements that manipulate Excel until
you
find the culprit. In other words, post a minimal sample to reproduce the
problem, so other people can take a look.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"Darrell Wesley" <Da***********@discussions.microsoft.com> escribió en el
mensaje news:96**********************************@microsof t.com...
>A VB2003 application upgraded to VB2005 that builds an Excel
>spreadsheet.
> Everything appears to work correctly except that the Excel object does
> not
> go
> away it is still in the Process list in task manager.
>
> This problem did not exist in the VB2003 version.
>
> Are there a any ideas of what might be happening?
>
> All of the Excel objects are being disposed of by setting them to
> Nothing
> and the Quit method is called for Excel. I've even used the
> System.Runtime.InteropServices.Marshal.ReleaseComO bject method as well
> as
> the
> WaitForPendingFinalizers method and nothing seems to effect this.
>
> At the applications END statement an error shows of
> "ObjectDisposedException
> was not handled".
>


Nov 23 '05 #5
I read it carefully. The item it does not mention is how to select a specific
sheet in the Workbook. But like I said this is different behavior then found
in VB6 or VB2003.

Here is the modified code that works:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim objExcel As Excel.Application
Dim xlWBs As Excel.Workbooks ' added
Dim xlWB As Excel.Workbook
Dim xlWS As Excel.Worksheet
Dim xlSheets As Excel.Sheets 'new object added

objExcel = New Excel.Application
xlWBs = objExcel.Workbooks ' added
xlWB = xlWBs.Add ' changed
xlSheets = objExcel.Sheets ' added
xlWS = xlSheets("Sheet1") ' changed
xlWS.Select()
NAR(xlWS)
NAR(xlSheets)
xlWB.Close()
NAR(xlWB)
NAR(xlWBs)
objexcel.Quit()
NAR(objexcel)
End Sub

Private Sub NAR(ByVal o As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComO bject(o)
Catch
Finally
o = Nothing
End Try
End Sub

"Carlos J. Quintero [VB MVP]" wrote:
Hi Darrell ,

In your sample code neither objexcel.Workbooks nor xlWB.Sheets are using a
explicit variable that is released explicitly later, so Excel will stay
alive...

Please read again CAREFULLY the article that I mentioned, the Resolution
section...

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"Darrell Wesley" <Da***********@discussions.microsoft.com> escribió en el
mensaje news:49**********************************@microsof t.com...
Carlos,

Even though I've resolved part of the problem I find that Excel does not
disappear from the Process list until the application terminates.

This is not a particular problem for this specific application but it
would
be for others especailly the ones that tend to remain open on the desktop
for
most of the day and Excel is used for a reporting tool.

Here's the sample code.

Imports Excel
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim objexcel As Excel.Application
Dim xlWB As Excel.Workbook
Dim xlWS As Excel.Worksheet
objexcel = New Excel.Application
xlWB = objexcel.Workbooks.Add
xlWS = xlWB.Sheets("Sheet1")
xlWS.Select()
System.Runtime.InteropServices.Marshal.ReleaseComO bject(xlWS)
xlWS = Nothing
xlWB.Close()
System.Runtime.InteropServices.Marshal.ReleaseComO bject(xlWB)
xlWB = Nothing
objexcel.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComO bject(objexcel)
objexcel = Nothing

End Sub
End Class

One other thing I'm using Excel 2000 the Object Library version 9.
"Carlos J. Quintero [VB MVP]" wrote:
I suppose that you have already read and applied:

Office application does not quit after automation from Visual Studio .NET
client
http://support.microsoft.com/default...b;en-us;317109

So, I would recommend to remove statements that manipulate Excel until
you
find the culprit. In other words, post a minimal sample to reproduce the
problem, so other people can take a look.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"Darrell Wesley" <Da***********@discussions.microsoft.com> escribió en el
mensaje news:96**********************************@microsof t.com...
>A VB2003 application upgraded to VB2005 that builds an Excel
>spreadsheet.
> Everything appears to work correctly except that the Excel object does
> not
> go
> away it is still in the Process list in task manager.
>
> This problem did not exist in the VB2003 version.
>
> Are there a any ideas of what might be happening?
>
> All of the Excel objects are being disposed of by setting them to
> Nothing
> and the Quit method is called for Excel. I've even used the
> System.Runtime.InteropServices.Marshal.ReleaseComO bject method as well
> as
> the
> WaitForPendingFinalizers method and nothing seems to effect this.
>
> At the applications END statement an error shows of
> "ObjectDisposedException
> was not handled".
>


Nov 23 '05 #6
Hi Darrell,
I read it carefully. The item it does not mention is how to select a
specific sheet in the Workbook.
It does not mention that, but it points that you need to use a variable each
time that you retrieve a property from the object model to release it later
explictly.

So, each time than in your code you see:

objexcel.Workbooks.Add

that will cause problems. And the same happens with:

xlWB.Sheets("Sheet1")

if you think that it is the short form of:

xlWB.Sheets.Item("Sheet1")
But like I said this is different behavior then found in VB6
Yes, due to COM Interop
or VB2003.


I don´t think so. The same should happen in VB2005, VB2003 or VB2002. In
fact, the article was written for VB.NET 2002 and VB.NET 2003, before VB
2005...

The proper way to debugging these things is start with:

Dim objexcel As Excel.Application

objexcel = New Excel.Application
objexcel.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComO bject(objexcel)
objexcel = Nothing

ensure that it releases Excel correctly, and each time that you add new
lines of code, check again that Excel is released.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

Nov 23 '05 #7

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

Similar topics

2
by: Jerry Spence1 | last post by:
1. Is there a more suitable, dedicated newsfeed for VB2005 yet? 2. I'm confused as to which version to get. I work for a small company and we will just need VB2005 on my PC. Therefore that tends...
1
by: zacks | last post by:
I am using the Microsoft Excel driver (DriverID 790) to process data in an Excel spreadsheet. One of the columns is money, but was orinally formatted as General. So a value in the spreadsheet of...
0
by: Rich | last post by:
Hello, I just upgraded a vb2003 app to vb2005. The vb2003 app had/has a statusbar object - which contains panels and I can see the properties of the statusbar in the properties window in...
1
by: erickwan88 | last post by:
I am doing a final year project for my school and is going to provide for an organization, so I am asking for some help on here. Indeed, I have no idea on how to get the input from my pen driver...
15
by: Aalaan | last post by:
I am presently a user of classic vb6 and hang out on those newsgroups. Some of you may be aware that there is a very anti MS and vb2005 feeling there. I have tried to get them to tell me which...
1
by: Jeffrey Christiansen | last post by:
I wanted to add a toggle button to a VB2005 form to be used for a simple Windows Application (i.e. compiled to a "*.exe"), so I added the ActiveX Microsoft Forms Object toggle button, however I...
0
by: kylancal | last post by:
When I launch a new instance of Excel from Visual Basic, my add ins don't work. I need to remove them and add them back in through code. This is very annoying as a button pops up alerting me that...
1
by: Vae07 | last post by:
Ok so here is a brief summary of my problem. I need a pop up form that submits input text box information to a pocket excel workbook upon a command botton click. Text box inputs are checked for...
0
by: arindams | last post by:
I'm getting problem in pasting HTML text in Excel 2007 whereas it is working fine in Excel 2003. The data pasted in excel 2007 is showing the the HTML code which is not desired. I need to have the...
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.