Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 6 of 6

Thread: Auto-Close Workbook&Application

  1. #1
    New Member
    Join Date
    Mar 2002
    Location
    Easton,PA USA
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    XL2000user:
    I would to use a macro to close its workbook and then shut down XL.
    The script below is what I was trying. Each statement runs by itself, but together the macro stops after the worksheet closes. The ap does not shut down.
    ???

    Todd

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Don't try and close the workbook first, use a statement to save it if necessary and then just use: -

    Application.Quit

  3. #3
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Newcastle, UK
    Posts
    1,174
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-03-04 12:06, ToddMc wrote:
    XL2000user:
    I would to use a macro to close its workbook and then shut down XL.
    The script below is what I was trying. Each statement runs by itself, but together the macro stops after the worksheet closes. The ap does not shut down.
    ???

    Todd
    Could you post the code?

    but, you might try putting the:

    Application.Quit

    in the Workbook_BeforeClose i.e:

    Private Sub Workbook_BeforeClose(Cancel As Boolean)

    Application.Quit

    End Sub


    Any help?
    "Have a good time......all the time"
    Ian Mac

  4. #4
    New Member
    Join Date
    Mar 2002
    Location
    Easton,PA USA
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    This is the script I was supposed to attach

    Private Sub Workbook_Open()
    Call Import '(macro name)
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Application.Quit
    End Sub

  5. #5
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Newcastle, UK
    Posts
    1,174
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Private Sub Workbook_BeforeClose(Cancel As Boolean)

    Application.Quit

    End Sub

    works for me??
    "Have a good time......all the time"
    Ian Mac

  6. #6
    New Member
    Join Date
    Mar 2002
    Location
    Easton,PA USA
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-03-04 12:49, Ian Mac wrote:
    Private Sub Workbook_BeforeClose(Cancel As Boolean)

    Application.Quit

    End Sub

    works for me??
    This works but the SaveChanges=False doesn't seem to work. Any suggestions?



    Private Sub Workbook_Open()
    Call Import
    Me.Close SaveChanges = False
    Application.Quit
    End Sub
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Application.Quit
    End Sub

Some videos you may like

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
  •