+ Reply to Thread
Results 1 to 5 of 5

Cannot Quit at this time Error

  1. #1
    Forum Contributor
    Join Date
    08-24-2006
    Location
    Sevenoaks, Kent
    MS-Off Ver
    Office 365 ProPlus
    Posts
    459

    Cannot Quit at this time Error

    Good afternoon,

    I hoping someone can help me because i'm completely baffled. Every morning at 8am have an excel file that opens up via a task scheduler command, after 56 minutes @ 8:56 excel trys to close of its own accord and I get this message from excel saying "Cannot Quit at this time" from a "Microsoft Visual Basic for Applications" pop up box, This stops everything from running and i have to clear the message before it will continue, once i clear the message it will run fine for the rest of the day until tomorrow at 8:56am. I can guarantee there is nothing in my vba code that attempts to close down my excel at this time. I will add all of my vba below.

    If anyone could help i would be really grateful.

    Module 1

    Please Login or Register  to view this content.
    Module 2

    Please Login or Register  to view this content.
    This Workbook

    Please Login or Register  to view this content.
    No other VBA is present in the sheet




    Thanks in advance DJ
    Last edited by djfatboyfats; 07-21-2016 at 07:23 AM.

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Cannot Quit at this time Error

    Hi,

    Why does your Refresh routine reschedule itself 3 times? It would seem to me that that will create an enormous schedule of refreshes quite quickly, and that probably conflicts with your scheduled Close routine, which may be trying to close while a connection is refreshing.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Cannot Quit at this time Error

    Please Login or Register  to view this content.

    This is confusing. Why schedule OnTime events; cancel them; then reschedule them?

    Also, this....
    Application.OnTime TimeValue("20:05:00"), "Refresh", , False
    Does not cancel this...
    Application.OnTime Now + TimeValue("00:00:30"), "Refresh"
    ...because the Now command makes the time values different between the two, and the On Error Resume Next hides the error.

    You could store the Now + TimeValue("00:00:30") value as a public variable then use that variable to cancel the event when necessary.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Forum Contributor
    Join Date
    08-24-2006
    Location
    Sevenoaks, Kent
    MS-Off Ver
    Office 365 ProPlus
    Posts
    459

    Re: Cannot Quit at this time Error

    The reason I cancelled events then rescheduled them is because i found if the workbook closed down in the day then reopened it would perform the same task twice or as many times the sheet opened and closed, which meant people was receiving multiple emails for the same data. I have made some code adjustments based on both your answers and im hoping the changes will resolve the problem. i will let you know tomorrow morning when it runs.

    Thanks

    DJ

  5. #5
    Forum Contributor
    Join Date
    08-24-2006
    Location
    Sevenoaks, Kent
    MS-Off Ver
    Office 365 ProPlus
    Posts
    459

    Re: Cannot Quit at this time Error

    First signs look promising. Thanks for your help guys.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Application.Quit Run-Time error 424???
    By biznez in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-14-2016, 04:07 PM
  2. Cannot Publish Excel Pivot Chart - Run Time Error
    By crisb184 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-11-2013, 07:04 AM
  3. run-time error ;2147023179 (800706b5) time automation error interface unknown
    By karthik72 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-02-2012, 09:31 AM
  4. [SOLVED] Truly quit Excel using Application.Quit doesn't work
    By bta in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-29-2012, 04:44 AM
  5. Quit on Error
    By dmartinez in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-28-2011, 01:27 PM
  6. quit on error
    By Ronbo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-15-2006, 05:40 PM
  7. Replies: 3
    Last Post: 08-01-2005, 03:05 PM

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