Results 1 to 10 of 10
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Application Quit; Server Side (XP; SP3)

    I have a number of scheduled tasks that open an Excel file and runs the code within that file. The final step is to exit Excel by using "application.quit".

    All this takes place on a server. When two scheduled tasks are running and the first one completes before the second task, "application.quit" is called and it appears that by quitting really means shutting down the Excel application.

    Other than rescheduling the tasks for a different time which would eliminate the stepping over of the process. Is there a better way to do this?

    Your assistance is appreciated,
    John

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

    Re: Application Quit; Server Side (XP; SP3)

    Can you provide information about how the workbooks are opened and the code execution is started?

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Application Quit; Server Side (XP; SP3)

    What do you want to happen?

    Quit the excel application is what "application.quit" means

    Steve

  4. #4
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Application Quit; Server Side (XP; SP3)

    Hans,

    Generally it is handled through an "Auto_Open" routine.

    Example:
    Sub Auto_Open()
    Run_Some_Code

    ActiveWorkbook.Save
    Application.Quit
    End Sub


    Regards,
    John

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

    Re: Application Quit; Server Side (XP; SP3)

    In that case, I think you'll have to schedule the tasks at different times.

  6. #6
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Application Quit; Server Side (XP; SP3)

    You could look at open workbooks and see how many are visible. If the visible count is 1 then you can quit, otherwise not quit.

    Steve

  7. #7
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Application Quit; Server Side (XP; SP3)

    Steve,

    Thanks for the idea. I found code here .

    John

  8. #8
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Application Quit; Server Side (XP; SP3)

    The code works great if you have various workbooks open in the same instance of Excel.

    Is there any tweaks that can be made to the code to determine the number of Excel instances?

    Thanks,
    John

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

    Re: Application Quit; Server Side (XP; SP3)

    But it shouldn't matter if another instance of Excel is open. Application.Quit will only close the current instance, so if another task is running in another instance of Excel, it won't be affected by Application.Quit in the current instance.

  10. #10
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Application Quit; Server Side (XP; SP3)

    Hans,

    I'll have to experiment with it a bit further. I thought I saw all instances of Excel trying to be closed; although I could be wrong.

    Regards,
    John

Posting Permissions

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