Results 1 to 5 of 5

Cannot Quit at this time Error

Threaded View

  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

    Sub Close_Workbook()
    Application.DisplayAlerts = False
    Application.Quit
    End Sub
    Module 2

    Sub Refresh()
    Application.OnTime Now + TimeValue("00:00:30"), "Refresh"
    If Worksheets("Data").Range("T2").Value = "" Then Exit Sub
    ActiveWorkbook.Connections("Query from csolve5").Refresh
    ActiveWorkbook.Connections("Query from csolve3").Refresh
    ActiveWorkbook.Connections("Connection").Refresh
    ''Application.Run "'Card Report v5.xlsm'!Refresh"
       
    Sheets("Data").Select
    Range("Table_Query_from_csolve[[#Headers],[DebtorID]]").Select
        Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
        Sheets("All Cards").Select
       ' Select the range of cells on the active worksheet.
       With Sheets("All Cards").Range("A1:I50")
       ActiveSheet.Range("A1:I50").Select
       End With
       ' Show the envelope on the ActiveWorkbook.
       ActiveWorkbook.EnvelopeVisible = True
       
       ' Set the optional introduction field thats adds
       ' some header text to the email body. It also sets
       ' the To and Subject lines. Finally the message
       ' is sent.
       With ActiveSheet.MailEnvelope
          '.Introduction = ""
          .Item.To = "[email protected]"
          '.Item.CC = "[email protected]"
          .Item.Subject = [Z1] & " " & Format(Date, "dd/mm/yy")
          .Item.Send
          Application.OnTime Now + TimeValue("00:00:30"), "Refresh"
          End With
          Application.OnTime Now + TimeValue("00:00:30"), "Refresh"
    End Sub
    This Workbook

    Private Sub Workbook_Open()
    
    
      Application.OnTime Now + TimeValue("00:00:30"), "Refresh"
      Application.OnTime TimeValue("20:15:00"), "Close_Workbook"
      
      'Cancel any previous scheduled run
        On Error Resume Next
        Application.OnTime TimeValue("20:05:00"), "Refresh", , False
        Application.OnTime TimeValue("20:15:00"), "Close_Workbook", , False
        On Error GoTo 0
    
    'Add scheduled run again
    Application.OnTime TimeValue("20:15:00"), "Close_Workbook"
        
         Set objmessage = CreateObject("CDO.Message")
          Set objconfig = CreateObject("CDO.Configuration")
           
          Recipients = "[email protected]"                                                               'Type in your own recipient'
          ''CC = ""                                                                                                      'Self Explanatory'
          ''BCC = ""                                                                                                     'Self Explanatory'
          From = "[email protected]"                                                                                          'No Spaces'
          Subject = "Card Report is Active - " & Format(Now(), "hh:mm")                                            'This can whatever the message needs to be
          HTMLBody = "*****File Opended Successfully*****"                                                                                    'This can whatever the message needs to be'"
          With objconfig.Fields
                      .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2                              'Do not change'
                      .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTP.local.1stcreditltd.com" 'This needs to the name of your compnay exchange'
                      .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30                 'Do not change'
                      .Update
          End With
          With objmessage
                      .Configuration = objconfig
                      .To = Recipients
                      .CC = CC
                      .BCC = BCC
                      .From = From
                      .Subject = Subject
                      .HTMLBody = HTMLBody
                      .Send
          End With
          'Destroy Objects
          'Set objmessage = Nothing
          'Set objconfig = Nothing
      
    ' VBMail Ends Here
    
        End Sub
    No other VBA is present in the sheet




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

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