Close Current File and Exit Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: Close Current File and Exit Excel

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    357
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    Is there anyway, from a macro, that I can close the active workbook and exit excel??

  2. #2
    BatCoder
    Join Date
    Feb 2002
    Location
    Turkey
    Posts
    799
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Application.Quit

    But if you have unsaved documents then you will be prompted.

    To avoid it and close workbooks without saving:
    '------CODE START-----
    Dim wrkBook As Workbook
    For Each wrkBook In Workbooks
    wrkBook.Saved = True
    Next
    Application.Quit
    '------CODE END-----

    or save all workbooks

    '------CODE START-----
    Dim wrkBook As Workbook
    For Each wrkBook In Workbooks
    wrkBook.Save
    Next
    Application.Quit
    '------CODE END-----

    regards


User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com