Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Sep 2001
    Location
    Blue Springs, Missouri, USA
    Posts
    108
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Quitting XL (XL2K3 SP1)

    I am trying to get Exel to quit but it is failing to do so. Here is my code.

    Private Sub ErrMsgQuit()
    Sheets(1).Activate
    msg = "You have failed three times to make and entry in this field. "
    msg = msg & "This application will now close. "
    DialogStyle = vbOKOnly + vbExclamation
    Title = "Missing Entry..."
    Response = MsgBox(msg, DialogStyle, Title)
    Application.DisplayAlerts = False
    ActiveWorkbook.Close
    Application.Quit
    End Sub

    Am I missing a step or is there something else I need to do to get Excel to close.

    Thanx.

    Dennis

    <img src=/S/gramps.gif border=0 alt=gramps width=20 height=20>

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Quitting XL (XL2K3 SP1)

    Remove the "Activeworkbook.Close" part.

    Maybe replace with ActiveWorkbook.Saved=True if you do not want the user to save changes.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Quitting XL (XL2K3 SP1)

    The moment you close the active workbook, the code stops running, so the instruction Application.Quit is never executed. To prevent Excel from trying to save the workbook when it quits, replace

    ActiveWorkbook.Close

    with

    ActiveWorkbook.Saved = True

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Quitting XL (XL2K3 SP1)

    We'll never know by how many seconds I beat you to it, with the exact same solution <bg>.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

Posting Permissions

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