DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: How to prevent/close multiple instances of Excel in VB6

Hybrid View

  1. #1
    Join Date
    Jun 2010

    Thumbs up [RESOLVED] How to prevent/close multiple instances of Excel in VB6

    [[[[[[[[[[[[[[[[[[[ RESOLVED: SEE FOR MORE INFO ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

    Hi I'm writing a program that accesses an Excel file (just one worksheet!) and displays selected rows in a form for users to view/modify. My problem is that every time I access, use, and close the Excel file it still keeps an instance running so that when I've exited my own program I'm left with several, often INVISIBLE, instances of the worksheet that I'm unable to close without the Task Manager. Is there anyway to avoid this? Why doesn't it just close and stop running with my code? Also, I've seen where some programmers are declaring their Excel apps, worksheets, and workbooks as OBJECTS, rather than as I have, below. What's the difference?

    Dim xl As New Excel.Application
    Dim xlsheet As Excel.Worksheet
    Dim xlbook As Excel.Workbook

    'body of code

    'disconnect from & close worksheet, workbook, Excel application
    Set xlsheet = Nothing
    xlbook.Close savechanges:=False 'depending on what i'm doing, sometimes True
    Set xlbook = Nothing
    Set xl = Nothing

    Thank You!
    Last edited by linziza; 06-23-2010 at 03:02 PM. Reason: RESOLVED

  2. #2
    Join Date
    Nov 2004
    I take it that the Excel file is an existing Excel file, right ? How are you creating the Excel application object ??

  3. #3
    Join Date
    Jun 2010
    hi, thanks for replying but I actually posted the same message on VBForums and had it answered last week! it's already been resolved

    sorry for the inconvenience... but thanks anyway!

  4. #4
    Join Date
    Nov 2004
    how did you resolve it ??

  5. #5
    Join Date
    Jun 2010
    Read my other thread here:

    i'm not really certain exactly how i fixed it... I just kept playing around with my code and eventually it worked! but follow the guys advice, especially si!

Similar Threads

  1. VB6 can't open excel sheet after it's created
    By MFB1 in forum VB Classic
    Replies: 8
    Last Post: 06-24-2008, 02:54 PM
  2. Detect Excel Version in VB6 Application
    By Ifgash in forum VB Classic
    Replies: 1
    Last Post: 04-23-2006, 02:58 AM
  3. Multiple instances of SQL 2000
    By Terry in forum Database
    Replies: 2
    Last Post: 03-20-2003, 11:29 AM
  4. Replies: 32
    Last Post: 08-14-2000, 10:55 AM
  5. Create Multiple Instances of Class at Runtime
    By Eric Jenkins in forum authorevents.appleman
    Replies: 1
    Last Post: 04-13-2000, 10:23 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
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center