Consulting

Results 1 to 7 of 7

Thread: Solved: Close Excel?

  1. #1
    VBAX Regular
    Joined
    Nov 2006
    Posts
    81
    Location

    Solved: Close Excel?

    What is the code to close Excel ,or can't one close excel with code? I can close the workbook but would like to close the program.
    Here is my code for a book.......[VBA]ActiveWorkbook.Close ("WB name..xls")[/VBA]
    Any help please.

  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Hi its
    [VBA]
    Application.Quit
    [/VBA]I think!

    Regards,
    Simon
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    VBAX Regular
    Joined
    Nov 2006
    Posts
    81
    Location
    Thanx but that only closes the workbook not excel.

  4. #4
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    The below is from here http://www.contextures.com/xlfaqMac.html#Close

    How do I close a file/close Excel with a macro?

    ActiveWorkbook.Close savechanges:=False 'true ??? --will close the active workbook Workbooks("mywkbk.xls").Close savechanges:=False 'true ??? --will close mywkbk.xls ThisWorkbook.Close savechanges:=False 'true ??? --will close the workbook that holds the code that's running. Application.Quit will close all of Excel. --Be careful with this one.

    Regards,

    SImon
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  5. #5
    VBAX Regular
    Joined
    Nov 2006
    Posts
    81
    Location
    A ha..... just had put it in the right place
    Thanx Simon.

  6. #6
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    [VBA]Private Sub CommandButton1_Click()
    Application.DisplayAlerts = False
    Application.Quit
    End Sub[/VBA]
    I use this. As Simon points out be careful as it closes without saving changes.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  7. #7
    VBAX Regular
    Joined
    Nov 2006
    Posts
    81
    Location
    Thanx all

Posting Permissions

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