June 25th, 2012, 10:15 AM
Excel Application - can't find declaration
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
(objExcel just being an example for a name)
Dim objExcel as Excel.Application
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
I get a compile time error.
Set Application = Nothing
is in the code to close the book and sheet.
Set objExcelBook = Nothing
Set objExcelSheet = Nothing
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:
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.
Dim wkbNew As Excel.Workbook
intOrigNumSheets = Application.SheetsInNewWorkbook
So could anyone give me some advice?
June 25th, 2012, 11:21 AM
Re: Excel Application - can't find declaration
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.
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!