Advanced issue; second instance of Excel will not go away!

G

Guest

Excel 2003/XP Pro

Using the Windows Task Manager I seem to have a instance of Excel.exe that
will not go away. My Addin creates a second instance of excel, works some
code and then closes itself, or so I thought. The file closes, the instance
disappears and returns me to the original instance, but I recently noticed
that the windows task manager still shows a process (not using resources 00)
.. Even if i close the original instance the process list just drops from 2
excel.exe on list to one. Although i have tried numerous manual and code
methods for closing I can only clear the Task manager list by rebooting.

if i run ym code it creates a list item in task manager for each run, so
without reboot I can get a long list.

Should I be concerned? Am i missing something in the shutdown?
Have listed the basic code snippits below


Public XLNewSpecial As Object
Public XLUser As Object

Set XLUser = GetObject(, "excel.application")
' so I can call the original instance when needed

Set XLNewSpecial = CreateObject("excel.application")
Application.Visible = True ' along withother settings

'code here to do suff

'explicit closing code

XLNewSpecial .Quit
Set XLNewSpecial = Nothing


The code looks like it works fine with the exception that the Task Manager
will not release my special instance of Excel with out a reboot. to be
specific WTM shhows a process but not the application, after my closing.
 
T

Tom Ogilvy

If you use any unqualified reference within your code you will get a ghost
reference which you have no way of releasing and you experience what you are
experiencing.

An unqualified reference might be

ActiveCell.value = 6

rather than

xlNewSpecial.ActiveCell.value = 6
 
G

Guest

Thanks Tom

i'll review my code

One Follow up, my new instance immediately opens an addin where the majority
of the code resides. It also opens a Template for displays.

I understand from your post that references to my template will need to be
qualified, however I just want to be sure that ThisWorkbook is still
considered a qualified reference.... example:
XLNewSpecial.MyTemplate.Sheets() and
ThisWorkbook.Sheets()
 
T

Tom Ogilvy

If you are running code from within the new instance, I can't say much about
that. You code wouldn't see that, so I doubt it would create this type of
problem unless it leaves your new instance in a state where it can't be
closed. My comments were aimed at the code that creates the new instance.
No matter how few the lines are, there is usually ample opportunity to
create a ghost reference.

but see Tushar's link.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top