excel object not going away

  • Thread starter Thread starter mcnews
  • Start date Start date
M

mcnews

got a problem with an excel app object not ending even after closing all
workbooks and quitting the app ala objExl.quit.
excel.exe continues to run in task manager.
windows 2000 and excel 2002.

any clues?

thanks,
mcnews.
 
Yep.
You are using a variable (probably implicitly created by Excel) that you do
not know exists so Excel is staying open.
You need to explicitly declare all variables and then set them to Nothing
prior to quitting Excel.

Dim objXL As Excel.Application
Dim objWBS As Excel.Workbooks
Dim objWB As Excel.Workbook
Dim objWS As Excel.Worksheet

objXL = CType(GetObject(, "Excel.Application"), Excel.Application)
'or
objXL = New Excel.Application

objWBS = objXL.Workbooks
objWB = objWBS.Add
objWS = CType(objWB.Worksheets(1), Excel.Worksheet)
objWS.Cells(1, colIndex) = col.ColumnName

objWS = Nothing
objWB = Nothing
objWBS = Nothing
objXL = Nothing
 
um...

Don't you need the keyword Set in front of most of those executable lines?

- Turtle
 
I think you missed the point.
Excel is creating an implicit variable and you don;t know what it is so you
can't set it to Nothing ince you didn't create it, Excel did.

So review each line of code and anytime you use an Excel method be sure it
is only done by a variable you created.
(I showed a list of some of them - there are more.)

Then set all of them to Nothing when done.
 
i see.
so if i use workbook i am probably using application even if i don't
explicitly create the object.
 
Back
Top