View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jon Peltier Jon Peltier is offline
external usenet poster
 
Posts: 6,582
Default Phantom VBA Projects (again)

The problem started on the day I installed a trial version of one of the
Spark Chart programs, and persisted until I restarted Excel immediately
after uninstalling the program. I don't suspect that the program caused it,
I know that the program caused it.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Peter T" <peter_t@discussions wrote in message
...
Personally I could never attribute the problem to some other addin, though
in discussion you referred to Jon Peltier seemed to suspect otherwise.

The ClosePhantoms routine was designed only to close a phantom "xls" that
had a path (ie previously saved) and assuming its fullname could be
obtained
and a reference set to it as a workbook.

If your phantoms are not as described above, ie previously saved addins,
try
the following and see if you can at least obtain a handle to your
phantom(s).

Sub Test()
Dim s$
Dim idx As Long, i As Long
Dim wb As Workbook
Dim vbp As Object

'' try both types of Loop, ie 'For Each' & 'For i = 1'
'' (comment 'Set vbp =' if looping 'For Each' )

'For Each vbp In Application.VBE.vbprojects
For i = 1 To Application.VBE.vbprojects.Count

idx = idx + 1
s = " - ": Set wb = Nothing: Err.Clear

On Error GoTo errH
Set vbp = Application.VBE.vbprojects(i) 'comment if For Each

On Error Resume Next

s = vbp.Filename
If s = " - " Then
' could be a non-phantom unsaved wb, eg "Book1"
' but not possible get the wb.name from vbp
' to set a wb reference
Err.Clear
s = s & vbp.Name

Else

s = Mid$(s, InStrRev(s, "\") + 1, 200)

Set wb = Workbooks(s)

End If
resNext:
Debug.Print idx, Err.Number, Not wb Is Nothing, s

Next

Exit Sub
errH:
Resume resNext

End Sub


If in this test you can set a reference to your phantom, put a break on
the
debug line and when you get to your phantom try -
wb.Close

If (?) that works it should be possible to adapt to distinguish normally
loaded files and attempt to delete only the phantom(s).

Regards,
Peter T


"Gizmo63" wrote in message
...
Hi all,

These well discussed phantom projects that remain even when the workbooks
are closed are a real pain.
Concensus seems to point to add-ins or VSTO items but here's the rub:
Corporately we all have the same build but no others have the same
problem
so that's VSTO out of my equation.

Of the other folk with this problem are any of you using Microstrategy
Office, Microstrategy Desktop or FastExcel. Office wise the only thing I

have
that no one else does is MSAccess.

These are the unique aspects to my pc.

FastExcel has been removed and the pc rebooted with no effect - could
something be left lurking?
Microstrategy is a pain to remove and reinstall so I'd like to leave this

as
a last option.

Peter T's subroutine to kill of the phantoms has no effect either.

Need some help - these ghosts are getting to me!