I don't know VB6 well.
I was given the task to debug some code (that someone else wrote) to find the reason why there remains an Excel.exe in the task manager, after the excel application that was started by this VB code was closed.
I can't upload all the code that deals with the Excel part. There is simply too much and one would get bogged down by it. However, I will try to explain and summarize what has been done, and what I see that could be possible problems.
First of all, I can't find a line such as
Dim objExcel as Excel.Application
(objExcel just being an example for a name)
The application just appears somehow, and is referenced as Application.
So Application.Quit is in the code, but it doesn't seem to work. If I put into the Immediate Window ?Application (while debugging) I still get Microsoft Excel as answer after the Quit statement.
If I say
Set Application = Nothing
I get a compile time error.
Set objExcelBook = Nothing
Set objExcelSheet = Nothing
is in the code to close the book and sheet.
If I look at where the Excel.exe appears in die Task Manager while debugging, (that is, unless I call ?Application in the Immediate Window) it appears when these lines are run:
Dim wkbNew As Excel.Workbook
intOrigNumSheets = Application.SheetsInNewWorkbook
How can the application just appear like that? I've read something about late binding, but I don't understand exactly how it works in this case.
I'm not the vba crack here, but Set application = Nothing is wrong, because Application is not a variable but an object. You can see if intellisense offers some method of the object which allows to Close or Unload or something to terminate it.
Type Application. and after typing the dot, intellisense should show you the properties and method of the object yhat you can use.