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

Excel Application.Quit doesn't

This should be a fairly common scenario, but I haven't yet found a solution
on google.

(On WinXP Pro SP2 / Access 2003 / Excel 2003)
The following code, when run from Access, leaves a copy of Excel.exe hanging
around.

'***********************************************
Sub testXL()

Dim objXL As Object
Dim wkbXL As Object
Dim strFileName As String

On Error GoTo errHandler
strFileName = "C:\Test.xls"
Set objXL = CreateObject("Excel.Application")
Set wkbXL = objXL.Workbooks.Open(strFileName)

exitHere:
On Error Resume Next
wkbXL.saved = True
wkbXL.Close

' also tried this
' wkbXL.Close savechanges:=False

Set wkbXL = Nothing
objXL.Quit
Set objXL = Nothing
On Error GoTo 0
Exit Sub

errHandler:
MsgBox (Err.Description)
Resume exitHere

End Sub
'***********************************************

Early binding seems to make no difference. Any ideas on how to release Excel
from memory would be appreciated.



Nov 13 '05 #1
4 16824
"Chuck Grimsby" <c.*******@worldnet.att.net.invalid> wrote in message
news:61********************************@4ax.com...

Generally, I do something like (using late binding):

Dim objExcel As Object
Set objExcel = CreateObject("excel.application")
objExcel.Workbooks.Open strFileName

<do whatever>

' Note: make sure you use .Save on every ActiveWorkbook
' that changes
objExcel.ActiveWorkbook.Save

objExcel.Application.Quit
Set objExcel = Nothing

Other then the ActiveWorkbook.Save statement, not too much difference
then the code you are using, however you might want to toss in a
"objExcel.Visible = True" statement to see what Excel is doing on the
screen. Occasionally, you can catch more then a few errors and
warnings which pop up that you'll have to deal with (Circular
references, macro warnings, etc.).


Hi Chuck, thanks for the reply. No luck with your code - I tried several
variations along the lines of ActiveWorkbook.Save and I'm still seeing the
pesky thing in memory. I also tried making objXL visible but nothing showed
up - it just hides itself after the Quit statement. I thought that there may
have been a dialog asking for user input (whether to run macros or some
such) but nothing like that.

I wonder if this is something to do with Excel 2003. I'll load an earlier
version onto another machine and try that.
Nov 13 '05 #2
Try it this way:

(Tools/References/Microsoft Excel Object Library)

Dim objExcel As Excel.Application, ...

Set objExcel = CreateObject("Excel.Application")
...
objExcel.Quit

I have also experimented with

Dim objExcel As New Excel.Application

which eliminates the Set objExcel statement, but did not have much
consistent luck with that. I have had consistent luck with Dim objExcel
As Excel.Application --- Set objExcel =
CreateObject("Excel.Application"), and GetObject also.
Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3
"Rich P" <rp*****@aol.com> wrote in message
news:41**********************@news.newsgroups.ws.. .
Try it this way:

(Tools/References/Microsoft Excel Object Library)

Dim objExcel As Excel.Application, ...

Set objExcel = CreateObject("Excel.Application")
..
objExcel.Quit

I have also experimented with

Dim objExcel As New Excel.Application

which eliminates the Set objExcel statement, but did not have much
consistent luck with that. I have had consistent luck with Dim objExcel
As Excel.Application --- Set objExcel =
CreateObject("Excel.Application"), and GetObject also.


Hi Rich. Same deal. I tried early binding, late binding, every which way.
I'm running out of ideas.

Wehn I get a chance I'll load up Excel 97 or 2K and see if the problem is
specific to Excel 2003.
Nov 13 '05 #4
"Chuck Grimsby" <c.*******@worldnet.att.net.invalid> wrote in message
news:hc********************************@4ax.com...
Generally, I do something like (using late binding):

Dim objExcel As Object
Set objExcel = CreateObject("excel.application")
objExcel.Workbooks.Open strFileName

<do whatever>

' Note: make sure you use .Save on every ActiveWorkbook
' that changes
objExcel.ActiveWorkbook.Save

objExcel.Application.Quit
Set objExcel = Nothing


No, still no difference. But I've found that this behaviour only occurs with
Excel 2003; not 2002 or 2000. Perhaps some new feature of Excel 2003 is not
letting the program quit. I've reproduced this on two different machines
here, both running Office 2003.

I think this might qualify as a bug. In the meantime I'm going to just have
to use brute force to close it.
Nov 13 '05 #5

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

Similar topics

1
by: Lize | last post by:
Hi, I'm writing an ASP application to open an excel workbook, then run a macro stored in the excel file, which produces outputs that will be displayed back onto my ASP application. Now the...
7
by: Mike | last post by:
Please help. I am using object.quit in an attempt to quit an excel application that I started with createobject ("Excel.Application"). The code executes, but does not stop the application. When...
3
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...
7
by: taylor.bryant | last post by:
I am running: Win XP SP2 Excel 2002, Access 2002 (Office XP SP3) Using Visual Basic (not VB.NET) At one point (prior to XP SP2?!? - I can't pin it down), this did not happen and I was easily...
1
by: u7djo | last post by:
Hi, I'm currently building a function in Access that creates an Excel spreadsheet but it doesn't look like the Excel object is being destroyed correctly as the Excel module is still showing in the...
0
by: acharyaks | last post by:
Hi life saver, I am using excel component for the development. The purpose is to connect to excel through the odbc connection string. Then through the connection extract data into a dataset and...
6
by: Matthew Wieder | last post by:
I have the following requirements: Build a stand-alone C# application that asks the user to click in a cell in an Excel spreadsheet, and then displays the address of that cell in the C#...
8
by: ChrisBowringGG | last post by:
When you use Application.Quit() on an Excel application, there can still be an instance of Excel running, as seen in Task Manager. You can try following the advice on MSDN: ...
16
by: LP | last post by:
Hello, I am trying to use .NET with Excel. I installed Office 2003 and selected ..NET programming suport option, so it installed all those PIA, as MS sugests. But I can not find a way to destroy...
16
by: alexia.bee | last post by:
Hi all, In some weird reason, excel instance won;t die if i remove the comment from 4 lines of setting values into struct. here is a snipcode public...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
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,...
0
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...
0
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,...

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.