Results 1 to 4 of 4

Thread: [RESOLVED] Excel.exe still running after Wb.close and x.quit

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2008
    Posts
    23

    Resolved [RESOLVED] Excel.exe still running after Wb.close and x.quit

    Hello there

    I am writing an export routine in MS acess 2000

    It opens up an excel file and I feed data into the worksheet, however when all is done, and the file is saved, and I send the command to close the excell application it looks liek excel closes fine, but it is still running in the background if I check the taskmanager, and it seems only when I close acess that excel also shuts down.

    Here is the start and end to my code
    ...

    Dim x As Excel.Application
    Dim ws As Excel.Worksheet
    Dim wb As Excel.Workbook
    Set x = New Excel.Application
    Set wb = x.Workbooks.Open("C:\templatefile.xls")
    x.Visible = True
    Set ws = wb.Worksheets("Sheet1")

    there is then some code which feeds information to specific cells in the worksheet, and that works fine...
    and at the end


    ws.SaveAs Wrk_File_Name
    wb.close
    x.Quit

    ...

    I set excel to be visible and it runs great, and the code to paste my information to cells and formating works great. at the end the applicaiton saves and the excel appears to close and I am returned to my access application. However, if I check excel.exe is still running in the background on my pc.

    any suggestions??

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Excel.exe still running after Wb.close and x.quit

    Welcome to VBForums

    As you are writing this in Access, it belongs in our Office Development forum, as the VB editor in Access (and other Office applications) is not VB 6, but VBA 6 which can often be different - Thread moved to Office Development forum

    Your "start" code is fine, and will not be the cause of this kind of problem. Your "end" code isn't quite right, as you don't Set the objects to Nothing - see post #4 of the Excel Tutorial that is linked from my signature for examples.

    The issue is actually likely to be in the part you didn't show us, and the things that are likely to cause it are explained in post #11 of the tutorial. Using methods like Cells or Range or Selection without an appropriate parent object is a well known cause of this kind of issue.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2008
    Posts
    23

    Re: Excel.exe still running after Wb.close and x.quit

    Thnks for the tips, I looked over your tutorial and it was quite helpful..

    it turned out that I was missing one parent object reference and once that was fixed the issue with excel staying open cleared itself up.

    Glad I found these forms, They will come in handy over the next few weeks I think.

    Take care..

    And Thanks again!!

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Excel.exe still running after Wb.close and x.quit

    I'm happy to help - and I'm impressed that you managed to sort it out yourself based on the advice given (most threads like this tend to go on for a while, as people tend to miss one or more items in their code!).


    As you now have it sorted out, could you please do us a little favour, and mark the thread as Resolved?
    (this saves time reading for those of us who like to answer questions, and also helps those who search to find answers)

    You can do this by clicking on "Thread tools" just above the first post in this thread, then "Mark thread resolved".

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