?
Solved

Late binding EXCEL Proceess stays active - VB6

Posted on 2006-07-20
3
Medium Priority
?
639 Views
Last Modified: 2012-05-05
Problem - for a late binding EXCEL app (VB6), the process remains in the task mgr.
(Windows XP, EXCEL 2000, VB6)

First - here is a sequence that works fine.

set  xlsapp = CreateObject("EXCEL.APPLICATION")
xlsapp.quit
Set xlsapp = nothing

With this sequence, the EXCEL process is ended, as indicated by viewing the Windows Task Mgr.


Second - here is a sequence that does not work - the EXCEL process remains active as indicated by viewing the Task Mgr

set  xlsapp = CreateObject("EXCEL.APPLICATION")

rows("10").Select  'this type of statement results in the EXCEL process remaining active in the TaskMgr

xlsapp.quit
Set xlsapp = nothing

Do I need to do something with the "rows" or "Selection" properties before quiiting xlsapp?

Any help is greatly appreciated.  Thank you
0
Comment
Question by:cfwti
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 37

Expert Comment

by:Harisha M G
ID: 17149833
Hi,

It may be a good idea to close the workbook before quitting

---
Harish
0
 
LVL 11

Accepted Solution

by:
pratap_r earned 1500 total points
ID: 17150105
This has something to do with how COM handles are referenced

Unless you release all references to the COM object it will not be unloaded from memory.

so instead of using
rows(10).select
you may need to do something like
set rows = xlapp.rows
...
set rows = nothing

please note that this has to be done to each and every reference. (To take the refcount back to 0)

hope this helps!

Enjoy!
Pratap
0
 

Author Comment

by:cfwti
ID: 17154339
Hi Pratap,

You certainly pointed me in the right direction.  The fix is shown below:

replace the the line of code --          rows(10).select

with  --           xlsapp.rows(10).select.

Apparantly, using the "rows" property (or any other application property) without the application prefix ("xlsapp.") creates an orphan.

Thanks,
cfwti
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Progress

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question