View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
MikeZz MikeZz is offline
external usenet poster
 
Posts: 152
Default xlApp.Quit - Doesn't Close Instance.... Any ideas?

Thanks Jim,
I'm running Office 2003.
Is it possible that there is either a VBA Option/Preference or maybe a
library that I don't have loaded which is required to run that command?

It's strange but I think when I ran code similar to this sequence at home
(Also 2003), it closed the instance and at work, it didn't. And if I recall,
it was the same Excel File so the same exact VBA Routine.

Baffeling, just Baffeling to me.

Thanks again for the help,
MikeZz

"Jim Thomlinson" wrote:

I can not address your memory usage as we will not be opening the same file.
As for creating a new instance of XL and then destroying that instance the
code you posted works on my machine. Here is what I ran and it created an
destroyed an instance of XL in the task manager... Th eonly changes was
removing non essential declarations and explicitly defining the data types...

Sub QuickNewAppTest()
Dim MasterFile As String
Dim Master As Workbook
Dim masterSht As Worksheet
Dim FileString As String

FileString = "C:\Test.xls"
Dim xlApp As New Excel.Application 'ADDED FOR MEMORY

Application.ScreenUpdating = False
xlApp.Application.Visible = True 'ADDED FOR MEMORY

xlApp.Workbooks.Open (FileString) 'Focus is now on the workbook 'ADDED FOR
MEMORY

Set Master = xlApp.ActiveWorkbook
Set masterSht = xlApp.ActiveSheet
MasterFile = Master.Name

Master.Close SaveChanges:=False

Set masterSht = Nothing
Set Master = Nothing
xlApp.Quit
Set xlApp = Nothing 'ADDED FOR MEMORY
Application.ScreenUpdating = True

End Sub
--
HTH...

Jim Thomlinson


"MikeZz" wrote:

Hi,
I've been having some memory problems and so I tried a little test.

According to this group and other resources, the routine below should open a
new file in a new xlApp, then upon closing, quiting, setting = nothing,
should remove it from the Task Manager.

However, it does not get rid of it. I can't see it in my windows toolbar as
an open file but it shows up in Task Manager. The other odd thing is that I
can re-run it multiple times (opening the same file) and sometimes and get
totally different Memory usage... one time it's 28MB, another it's only 15MB.

Thanks for any thoughts,
MikeZz


Sub QuickNewAppTest()
Dim MasterFile
Dim f, c, r
Dim Master As Workbook
Dim masterSht As Worksheet
Dim FileString

FileString = "S:\ATCCommon\SALES\gm\Contracts\00New\Excel\C-0C5D0-000-011.xls"
Dim xlApp As New Excel.Application 'ADDED FOR MEMORY

Application.ScreenUpdating = False
xlApp.Application.Visible = True 'ADDED FOR MEMORY

xlApp.Workbooks.Open (FileString) 'Focus is now on the workbook 'ADDED FOR
MEMORY

Set Master = xlApp.ActiveWorkbook
Set masterSht = xlApp.ActiveSheet
MasterFile = Master.Name

Master.Close SaveChanges:=False

Set masterSht = Nothing
Set Master = Nothing
xlApp.Quit
Set xlApp = Nothing 'ADDED FOR MEMORY
Application.ScreenUpdating = True

End Sub