Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New Technique: Pesky Excel Application Object...won't go AWAY Closed, but an answer found.

Status
Not open for further replies.

plungerman

Programmer
Apr 29, 2013
5
I was trying to close Excel from VB 6, or VBA and reopen the same workbook when the routine was run again.
This was made impossible as the Excel process would stay alive (observed on the Task Manager) no matter how much closing
I did.

After trying all the possible answers (thanks, guys!) I had to find my own way (as is always the case
for the true Quest).

I took my block of [Excel Object, Workbook... Closing] code from the bottom of the sub and pasted it to
just below the first creation of the workbook instance, to verify that the object really got wiped out. Then moved this block one step at a time to beneath each reference to cell, sheet, range etc. and verify it was closing then. I would kill the excel process from Task Manager if the code did not, then restart from the Open Excel commands at the top.

Stepping through this way I was able to verify that the Close commands were actually getting rid of the Excel object
right up until they didn't. I was also able to add each close, or = nothing, element to the Close block as it went from the top
through all the code to the bottom. I also started closing in reverse order from opening as reccomended.

This was in fact ridiculous but did indeed nail that pesky range reference responsible for keeping the object open.
This was easily rewritten (don't know why one works but not the other) and the problem was gone.

All threads referring to this issue have been close so I'm the last one to figure it out, but I thought this technique might be of some interest to those still doing battle with this issue.


 
and your code is?????

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Hi,

Well, the code would not apply to anyone's case.

Just the notion of moving the Close block down through the code to inspect the

Close/Doesn't Close nature of the Excel objects.

Thanks
 
the code regarding the excel application object in particular!

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top