+ Reply to Thread
Results 1 to 10 of 10

Application.quit problem

  1. #1
    Registered User
    Join Date
    08-26-2009
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2003
    Posts
    10

    Application.quit problem

    I have a macro that once it's run, it quits the application. The problem is that once it activates, it closes all the excel worksheets. What I want to happen is that if it is the only excel workbook open I want the application to quit, but if there is another workbook open I want it to just close itself only and leave the other ones alone.

    Any help would be appreciated.

  2. #2
    Forum Contributor
    Join Date
    09-02-2005
    Posts
    146

    Re: Application.quit problem

    use:

    workbooks("Workbookname.xls").close true/false
    True - saves changes
    False - close without saving changes.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Application.quit problem

    If the code is running in the workbook to be closed, then
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    08-26-2009
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Application.quit problem

    Thanks for replying.

    That does work but the problem is, that by using it, when the workbook is the only one open, the excel application itself is still open when the workbook closes. What I need to happen is that if it's the only workbook open, it shuts doen everything including the application and if there is another workbook open I need it to just shut that workbook only and not the application.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Application.quit problem

    Perhaps ...
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    08-26-2009
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Application.quit problem

    Awesome!

    But a quick question what does this part of the statement mean

    If .Count = 1 Or (.Count = 2 And .Item(1).Name = "Personal.xls") Then

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Application.quit problem

    If you have two workbooks open, and one is personal.xls, it closes the application.

  8. #8
    Registered User
    Join Date
    08-26-2009
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Application.quit problem

    Is personal.xls a special kind of workbook or is it just any workbook of my choice?

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Application.quit problem

    It's a particular workbook: http://www.rondebruin.nl/personal.htm

  10. #10
    Registered User
    Join Date
    08-26-2009
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Application.quit problem

    Awesome. Thank you again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1