Excel Application - can't find declaration
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Excel Application - can't find declaration

  1. #1
    Join Date
    Jun 2012
    Posts
    1

    Excel Application - can't find declaration

    Hi!

    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
    Code:
    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
    Code:
    Set Application = Nothing
    I get a compile time error.

    Code:
    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:
    Code:
        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.


    So could anyone give me some advice?

  2. #2
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,722

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center