+ Reply to Thread
Results 1 to 6 of 6

Code for closing excel

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-24-2009
    Location
    SCOTLAND
    MS-Off Ver
    Excel Version 2308
    Posts
    151

    Code for closing excel

    I’m sure this simple coding for you smart guys out there. Any help thankfully received and appreciated.
    I know this is the code to close a workbook
    ActiveWorkbook.Close
    What is the coding required to close Excel altogether without saving changes or giving the option to save changes?
    Last edited by heliskier89; 07-12-2009 at 02:01 PM.

  2. #2
    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: Code for closing excel

    Sub OuttaHere()
        Dim wkb     As Workbook
    
        For Each wkb In Application.Workbooks
            If wkb.Name <> ThisWorkbook.Name And _
               wkb.Name <> "Personal.xls" Then wkb.Close SaveChanges:=False
        Next wkb
        ThisWorkbook.Saved = True
        Application.Quit
    End Sub
    Last edited by shg; 07-11-2009 at 05:28 PM.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    07-10-2009
    Location
    Denmark
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Code for closing excel

    Sub close_Excel()
    Application.Quit
    End Sub

  4. #4
    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: Code for closing excel

    Excel2003, please edit your post to add code tags.

  5. #5
    Forum Contributor
    Join Date
    06-24-2009
    Location
    SCOTLAND
    MS-Off Ver
    Excel Version 2308
    Posts
    151

    Re: Code for closing excel

    Worked great. Thanks alot shg.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Code for closing excel

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ 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