Results 1 to 10 of 10

Thread: [RESOLVED] Excel process not closing

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Resolved [RESOLVED] Excel process not closing

    I have a simple procedure that opens an Excel workbook (Excel 10) and updates it. However even after Closing, Quiting and setting all objects to nothing the Excel process does not shut down - until the VB application is closed.

    I was able to replicate the problem with this code which does nothing more than open the book and reference some objects.

    VB Code:
    1. Dim objExcel As Excel.Application
    2.     Dim objBook As Excel.Workbook
    3.     Dim objSheet As Excel.Worksheet
    4.     Dim objRange As Range
    5.    
    6.     Set objExcel = New Excel.Application
    7.     Set objBook = objExcel.Workbooks.Open("C:\Testing.xls")
    8.                
    9.     Set objSheet = objBook.Worksheets(1)                
    10.     Set objRange = objSheet.Range(Cells(1, 1), Cells(1, 2))
    11.  
    12.     Set objRange = Nothing
    13.     Set objSheet = Nothing
    14.    
    15.     objBook.Close False
    16.     Set objBook = Nothing
    17.    
    18.     objExcel.Quit
    19.     Set objExcel = Nothing

    The Excel process will shutdown if I comment out this line
    Set objRange = objSheet.Range(Cells(1, 1), Cells(1, 2))

    Something about that Range object is keeping Excel alive. Is there another method I should be using that will release the Range object? Setting it to nothing does not work.
    Last edited by brucevde; Jul 13th, 2006 at 04:27 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width